This commit is contained in:
parent
7e91801a59
commit
87bba3ea0f
6
pom.xml
6
pom.xml
|
|
@ -31,6 +31,7 @@
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- Spring boot -->
|
<!-- Spring boot -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
|
@ -103,6 +104,11 @@
|
||||||
<artifactId>springfox-swagger-ui</artifactId>
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
<version>2.9.2</version>
|
<version>2.9.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-beanutils</groupId>
|
||||||
|
<artifactId>commons-beanutils</artifactId>
|
||||||
|
<version>1.9.4</version> <!-- 或者更高版本 -->
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,122 @@
|
||||||
|
package com.syjiaer.clinic.server.common.util;
|
||||||
|
|
||||||
|
import com.syjiaer.clinic.server.common.exception.MessageException;
|
||||||
|
import org.apache.commons.beanutils.BeanUtils;
|
||||||
|
import org.springframework.beans.BeanWrapperImpl;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class VoUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 合并两个实体类列表
|
||||||
|
* @param mainList 主列表(以该列表数据为基础)
|
||||||
|
* @param subList 待合并列表
|
||||||
|
* @param linkField 关联字段名
|
||||||
|
* @return 合并后的List<Map>
|
||||||
|
*/
|
||||||
|
public static <T, E> List<Map<String, Object>> mergeEntities(
|
||||||
|
List<T> mainList,
|
||||||
|
List<E> subList,
|
||||||
|
String linkField) {
|
||||||
|
|
||||||
|
// 将主列表转换为以关联字段为Key的Map
|
||||||
|
Map<Object, T> mainMap = mainList.stream()
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
e -> getFieldValue(e, linkField),
|
||||||
|
e -> e,
|
||||||
|
(existing, replacement) -> existing));
|
||||||
|
|
||||||
|
// 创建结果容器
|
||||||
|
List<Map<String, Object>> result = new ArrayList<>();
|
||||||
|
|
||||||
|
// 处理主列表元素
|
||||||
|
for (T mainEntity : mainList) {
|
||||||
|
Map<String, Object> mergedMap = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
// 主实体转Map
|
||||||
|
try {
|
||||||
|
Map<String, String> describe = BeanUtils.describe(mainEntity);
|
||||||
|
describe.forEach((k, v) -> {
|
||||||
|
if (!"class".equals(k)) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
mergedMap.put(k, v == null ? null : mainEntity.getClass().getMethod("get" + capitalize(k)).invoke(mainEntity));
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
throw new MessageException(e.getMessage());
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
throw new MessageException(e.getMessage());
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
throw new MessageException(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new MessageException("Failed to describe main entity", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查找关联的子实体
|
||||||
|
Object linkValue = getFieldValue(mainEntity, linkField);
|
||||||
|
|
||||||
|
subList.stream()
|
||||||
|
.filter(sub -> Objects.equals(getFieldValue(sub, linkField), linkValue))
|
||||||
|
.findFirst()
|
||||||
|
.ifPresent(subEntity -> {
|
||||||
|
// 合并子实体属性
|
||||||
|
try {
|
||||||
|
Map<String, String> subDescribe = BeanUtils.describe(subEntity);
|
||||||
|
subDescribe.forEach((k, v) -> {
|
||||||
|
if (!"class".equals(k) && v != null) {
|
||||||
|
try {
|
||||||
|
mergedMap.put(k, subEntity.getClass().getMethod("get" + capitalize(k)).invoke(subEntity));
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
throw new MessageException(e.getMessage());
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
throw new MessageException(e.getMessage());
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
throw new MessageException(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (Exception ex) {
|
||||||
|
throw new MessageException("Failed to describe sub entity", ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
result.add(mergedMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取对象指定字段的值
|
||||||
|
* @param obj 对象
|
||||||
|
* @param fieldName 字段名
|
||||||
|
* @return 字段值
|
||||||
|
*/
|
||||||
|
private static <T> Object getFieldValue(T obj, String fieldName) {
|
||||||
|
try {
|
||||||
|
Method method = new BeanWrapperImpl(obj).getPropertyDescriptor(fieldName).getReadMethod();
|
||||||
|
return method.invoke(obj);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("Failed to get field value: " + fieldName, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 首字母大写
|
||||||
|
* @param str 字符串
|
||||||
|
* @return 转换后的字符串
|
||||||
|
*/
|
||||||
|
private static String capitalize(String str) {
|
||||||
|
if (str == null || str.isEmpty()) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
return str.substring(0, 1).toUpperCase() + str.substring(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -14,11 +14,11 @@ import java.util.Map;
|
||||||
|
|
||||||
public abstract class BaseController {
|
public abstract class BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private InfoUtil infoUtil;
|
protected InfoUtil infoUtil;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ParmsUtil parmsUtil;
|
protected ParmsUtil parmsUtil;
|
||||||
@Autowired
|
@Autowired
|
||||||
private HeadersUtil headersUtil;
|
protected HeadersUtil headersUtil;
|
||||||
|
|
||||||
// 使用 ThreadLocal 来缓存请求参数
|
// 使用 ThreadLocal 来缓存请求参数
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
package com.syjiaer.clinic.server.controller.inventory;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.syjiaer.clinic.server.common.constants.Constants;
|
||||||
|
import com.syjiaer.clinic.server.common.enums.InventorySocialTypeEnum;
|
||||||
|
import com.syjiaer.clinic.server.common.enums.InventoryTypeEnum;
|
||||||
|
import com.syjiaer.clinic.server.common.exception.MessageException;
|
||||||
|
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.inventory.InventoryApply;
|
||||||
|
import com.syjiaer.clinic.server.entity.inventory.dto.ApplyOrderQuery;
|
||||||
|
import com.syjiaer.clinic.server.service.inventory.InventoryApplyService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/inventory/apply")
|
||||||
|
public class InventoryApplyController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private InventoryApplyService inventoryApplyService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建领用单并领用
|
||||||
|
*/
|
||||||
|
@RequestMapping("/create")
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Result create() {
|
||||||
|
List<Map> mapList = parmsUtil.getList("data",Map.class);
|
||||||
|
InventoryApply useInfo = parmsUtil.getObject("useInfo", InventoryApply.class);
|
||||||
|
inventoryApplyService.create(mapList,useInfo);
|
||||||
|
return success();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询领用单
|
||||||
|
*/
|
||||||
|
@RequestMapping("/list")
|
||||||
|
public Result<Page> list() {
|
||||||
|
ApplyOrderQuery query = parmsUtil.getObject("query", ApplyOrderQuery.class);
|
||||||
|
if (query == null){
|
||||||
|
return error("没有带查询条件");
|
||||||
|
}
|
||||||
|
QueryWrapper<InventoryApply> queryWrapper = new QueryWrapper<>();
|
||||||
|
if(query.getPageNum() == null || query.getPageNum() == 0){
|
||||||
|
query.setPageNum(1);
|
||||||
|
}
|
||||||
|
if (query.getPageSize() == null || query.getPageSize() == 0){
|
||||||
|
query.setPageSize(Constants.DetailPageSize);
|
||||||
|
}
|
||||||
|
Page<InventoryApply> inventoryApplyPage = inventoryApplyService.listPage(query);
|
||||||
|
return success(inventoryApplyPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取领用单详情
|
||||||
|
*/
|
||||||
|
@RequestMapping("/getApplyDetail")
|
||||||
|
public Result<String> getCheckDetail(){
|
||||||
|
Integer applyId = parmsUtil.getInteger("id", "id不能为空");
|
||||||
|
return success(inventoryApplyService.getCheckDetail(applyId));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,65 @@
|
||||||
|
package com.syjiaer.clinic.server.controller.inventory;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.syjiaer.clinic.server.common.constants.Constants;
|
||||||
|
import com.syjiaer.clinic.server.common.enums.InventorySocialTypeEnum;
|
||||||
|
import com.syjiaer.clinic.server.common.enums.InventoryTypeEnum;
|
||||||
|
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.inventory.InventoryCheck;
|
||||||
|
import com.syjiaer.clinic.server.entity.inventory.dto.CheckQuery;
|
||||||
|
import com.syjiaer.clinic.server.service.inventory.InventoryCheckService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/inventory/check")
|
||||||
|
public class InventoryCheckController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private InventoryCheckService inventoryCheckService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 盘点列表分页查询
|
||||||
|
*/
|
||||||
|
@RequestMapping("/list")
|
||||||
|
public Result<Page<InventoryCheck>> list() {
|
||||||
|
CheckQuery query= parmsUtil.getObject("query", CheckQuery.class);
|
||||||
|
if (query == null){
|
||||||
|
return error("没有带查询条件");
|
||||||
|
}
|
||||||
|
return success(inventoryCheckService.listPage(query));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存盘点记录
|
||||||
|
*/
|
||||||
|
@RequestMapping("/save")
|
||||||
|
@Transactional
|
||||||
|
public Result save() {
|
||||||
|
List<Map> list = parmsUtil.getList("list", Map.class);
|
||||||
|
String remark = parmsUtil.getString("remark");
|
||||||
|
inventoryCheckService.save(list,remark);
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取盘点单详情
|
||||||
|
*/
|
||||||
|
@RequestMapping("/getCheckDetail")
|
||||||
|
public Result<String> getCheckDetail(){
|
||||||
|
Integer checkId = parmsUtil.getInteger("id", "id不能为空");
|
||||||
|
return success(inventoryCheckService.getCheckDetail(checkId));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,37 +1,148 @@
|
||||||
package com.syjiaer.clinic.server.controller.inventory;
|
package com.syjiaer.clinic.server.controller.inventory;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
|
import com.syjiaer.clinic.server.common.enums.InventorySocialTypeEnum;
|
||||||
|
import com.syjiaer.clinic.server.common.enums.InventoryTypeEnum;
|
||||||
|
import com.syjiaer.clinic.server.common.enums.UploadStatusEnum;
|
||||||
|
import com.syjiaer.clinic.server.common.util.DateUtil;
|
||||||
import com.syjiaer.clinic.server.common.vo.Result;
|
import com.syjiaer.clinic.server.common.vo.Result;
|
||||||
import com.syjiaer.clinic.server.controller.BaseController;
|
import com.syjiaer.clinic.server.controller.BaseController;
|
||||||
|
import com.syjiaer.clinic.server.entity.goods.Goods;
|
||||||
import com.syjiaer.clinic.server.entity.inventory.Inventory;
|
import com.syjiaer.clinic.server.entity.inventory.Inventory;
|
||||||
|
import com.syjiaer.clinic.server.entity.manager.ManagerUser;
|
||||||
import com.syjiaer.clinic.server.service.goods.GoodsService;
|
import com.syjiaer.clinic.server.service.goods.GoodsService;
|
||||||
import com.syjiaer.clinic.server.service.inventory.InventoryPurchaseService;
|
import com.syjiaer.clinic.server.service.inventory.InventoryPurchaseService;
|
||||||
import com.syjiaer.clinic.server.service.inventory.InventoryService;
|
import com.syjiaer.clinic.server.service.inventory.InventoryService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/inventory/goods")
|
@RequestMapping("/inventory/goods")
|
||||||
public class InventoryController extends BaseController {
|
public class InventoryController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private GoodsService iGoodsService;
|
private GoodsService goodsService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private InventoryPurchaseService iInventoryPurchaseService;
|
private InventoryPurchaseService iInventoryPurchaseService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private InventoryService iInventoryService;
|
private InventoryService inventoryService;
|
||||||
/**
|
/**
|
||||||
*根据采购单code 获取采购单信息
|
*根据采购单code 获取采购单信息
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/listByOrderCode")
|
@RequestMapping("/listByOrderCode")
|
||||||
public Result<List<Inventory>> listByOrderCode() {
|
public Result<List<Inventory>> listByOrderCode() {
|
||||||
String orderCode = parmsUtil.getString("orderCode", "请输入订单号");
|
String purchaseCode = parmsUtil.getString("orderCode", "请输入订单号");
|
||||||
QueryWrapper queryWrapper = new QueryWrapper();
|
return success(inventoryService.listByPurchaseCode(purchaseCode));
|
||||||
queryWrapper.eq("inventory_purchase_code", orderCode);
|
}
|
||||||
return success(iInventoryService.list(queryWrapper));
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据goodsId 获取该goods的所有库存信息 带库存总量
|
||||||
|
*/
|
||||||
|
@RequestMapping("/getByGoodsId")
|
||||||
|
public Result<Map<String, Object>> getByGoodsId() {
|
||||||
|
int goodsId = parmsUtil.getInteger("goodsId", "请输入商品ID");
|
||||||
|
|
||||||
|
Goods goods = goodsService.getById(goodsId);
|
||||||
|
if (goods == null) {
|
||||||
|
return error("商品不存在");
|
||||||
|
}
|
||||||
|
Map<String, Object> goodsMap = JSON.parseObject(JSON.toJSONString(goods), Map.class);
|
||||||
|
List<Inventory> list = inventoryService.getListByGoodsId(goodsId);
|
||||||
|
List<Map<String, Object>> listMap = new ArrayList<>();
|
||||||
|
for (Inventory inventory : list) {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("id", inventory.getId());
|
||||||
|
map.put("wholeNumber", inventory.getWholeNumber());
|
||||||
|
map.put("fragmentNumber", inventory.getFragmentNumber());
|
||||||
|
map.put("productionBatchCode", inventory.getProductionBatchCode());
|
||||||
|
map.put("productionDate", inventory.getProductionDate());
|
||||||
|
map.put("expiryDate", inventory.getExpiryDate());
|
||||||
|
map.put("purchaseUnitPrice", inventory.getPurchaseUnitPrice());
|
||||||
|
listMap.add(map);
|
||||||
|
}
|
||||||
|
goodsMap.put("inventoryGoodsList", listMap);
|
||||||
|
Map<String, Integer> map = inventoryService.totalNumber(goodsId);
|
||||||
|
goodsMap.putAll(map);
|
||||||
|
return success(goodsMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据goodsId 获取该goods的所有库存信息
|
||||||
|
*/
|
||||||
|
@RequestMapping("/getListByGoodsId")
|
||||||
|
public Result<List<Inventory>> getListByGoodsId() {
|
||||||
|
int goodsId = parmsUtil.getInteger("goodsId", "请输入商品ID");
|
||||||
|
Goods goods = goodsService.getById(goodsId);
|
||||||
|
if (goods == null) {
|
||||||
|
return error("商品不存在");
|
||||||
|
}
|
||||||
|
List<Inventory> list = inventoryService.getListByGoodsId(goodsId);
|
||||||
|
return success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id集合获取库存信息
|
||||||
|
*/
|
||||||
|
@RequestMapping("/getListByIds")
|
||||||
|
public Result<List<Inventory>> getListByIds() {
|
||||||
|
List<Integer> ids = parmsUtil.getIntList("idList");
|
||||||
|
if (ids == null || ids.isEmpty()) {
|
||||||
|
return success(new ArrayList<>());
|
||||||
|
}
|
||||||
|
List<Inventory> list = inventoryService.getListByIds(ids);
|
||||||
|
return success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 进销存统计
|
||||||
|
*/
|
||||||
|
@RequestMapping("/getInventoryStatistics")
|
||||||
|
public Result< List<InventoryService.LineModel>> getInventoryStatistics() {
|
||||||
|
int goodsId = parmsUtil.getInteger("goodsId","请选择商品id");
|
||||||
|
String startDateStr = parmsUtil.getString("startDate","请选择开始时间");
|
||||||
|
String endDateStr= parmsUtil.getString("endDate","请选择结束时间");
|
||||||
|
LocalDateTime startDateTime = DateUtil.getDateTime(startDateStr);
|
||||||
|
LocalDateTime endDateTime = DateUtil.getDateTime(endDateStr).plusDays(1);
|
||||||
|
List<InventoryService.LineModel> inventoryStatistics = inventoryService.getInventoryStatistics(goodsId, startDateTime, endDateTime);
|
||||||
|
return success(inventoryStatistics);
|
||||||
|
}
|
||||||
|
|
||||||
|
//todo getInventoryLog
|
||||||
|
@RequestMapping("/getInventoryLog")
|
||||||
|
public Result<List<Map<String, Object>>> getInventoryLog() {
|
||||||
|
int goodsId = parmsUtil.getInteger("goodsId","请选择商品id");
|
||||||
|
String startDateStr = parmsUtil.getString("startDate","请选择开始时间");
|
||||||
|
String endDateStr= parmsUtil.getString("endDate","请选择结束时间");
|
||||||
|
LocalDateTime startDateTime = DateUtil.getDateTime(startDateStr);
|
||||||
|
LocalDateTime endDateTime = DateUtil.getDateTime(endDateStr).plusDays(1);
|
||||||
|
List<Map<String, Object>> inventoryStatistics = inventoryService.getInventoryLogByGoodsId(goodsId, startDateTime, endDateTime);
|
||||||
|
return success(inventoryStatistics);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采购单 采购项修改
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping("/update")
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Result update() {
|
||||||
|
List<Inventory> list = parmsUtil.getList("list", Inventory.class);
|
||||||
|
inventoryService.updatePurchaseItem(list);
|
||||||
|
return success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,134 @@
|
||||||
|
package com.syjiaer.clinic.server.controller.inventory;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
|
import com.syjiaer.clinic.server.common.constants.Constants;
|
||||||
|
import com.syjiaer.clinic.server.common.enums.InventorySocialTypeEnum;
|
||||||
|
import com.syjiaer.clinic.server.common.enums.InventoryTypeEnum;
|
||||||
|
import com.syjiaer.clinic.server.common.enums.UploadStatusEnum;
|
||||||
|
import com.syjiaer.clinic.server.common.exception.MessageException;
|
||||||
|
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.inventory.Inventory;
|
||||||
|
import com.syjiaer.clinic.server.entity.inventory.InventoryPurchase;
|
||||||
|
import com.syjiaer.clinic.server.entity.inventory.dto.PurchaseOrderQuery;
|
||||||
|
import com.syjiaer.clinic.server.entity.inventory.vo.InventoryPurchaseVo;
|
||||||
|
import com.syjiaer.clinic.server.service.inventory.InventoryPurchaseService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author NiuZiYuan
|
||||||
|
* @since 2025-02-26
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/inventory/order")
|
||||||
|
public class InventoryPurchaseController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private InventoryPurchaseService inventoryPurchaseService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建采购单
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping("/create")
|
||||||
|
public Result<Object> create() {
|
||||||
|
InventoryPurchase purchase_order = parmsUtil.getObject("inventoryOrder", InventoryPurchase.class);
|
||||||
|
List<Inventory> list = parmsUtil.getList("inventoryOrderGoodsList", Inventory.class, "请至少采购一件商品");
|
||||||
|
inventoryPurchaseService.create(purchase_order,list);
|
||||||
|
return success();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查采购单
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping("/list")
|
||||||
|
public Result<Page<InventoryPurchaseVo>> list() {
|
||||||
|
PurchaseOrderQuery query = parmsUtil.getObject("query", PurchaseOrderQuery.class);
|
||||||
|
if (query == null) {
|
||||||
|
return error("没有带查询条件");
|
||||||
|
}
|
||||||
|
if (query.getPageNum() == null || query.getPageNum() == 0) {
|
||||||
|
query.setPageNum(1);
|
||||||
|
}
|
||||||
|
if (query.getPageSize() == null || query.getPageSize() == 0) {
|
||||||
|
query.setPageSize(Constants.DetailPageSize);
|
||||||
|
}
|
||||||
|
return success(inventoryPurchaseService.listPage(query));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取采购单详情
|
||||||
|
*/
|
||||||
|
@RequestMapping("/detail")
|
||||||
|
public Result<Map<String, Object>> detail() {
|
||||||
|
String code = parmsUtil.getString("code","采购单号不能为空");
|
||||||
|
Map<String, Object> byCode = inventoryPurchaseService.getByCode(code);
|
||||||
|
return success(byCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新采购单基本信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping("/update")
|
||||||
|
public Result update() {
|
||||||
|
InventoryPurchase inventoryOrder = parmsUtil.getObject("inventoryOrder", InventoryPurchase.class);
|
||||||
|
if (inventoryOrder.getInvoiceCode() == null || inventoryOrder.getInvoiceCode().isEmpty()) {
|
||||||
|
inventoryOrder.setInvoiceCode("无");
|
||||||
|
}
|
||||||
|
inventoryPurchaseService.updateById(inventoryOrder);
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采购单修改时 添加采购的商品
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping("/addOneGoods")
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Result addOneGoods() {
|
||||||
|
Inventory inventory = parmsUtil.getObject("data", Inventory.class);
|
||||||
|
if (inventory == null) {
|
||||||
|
return error("库存商品为空");
|
||||||
|
}
|
||||||
|
if (inventory.getInventoryPurchaseCode() == null) {
|
||||||
|
return error("订单为空");
|
||||||
|
}
|
||||||
|
inventoryPurchaseService.addOneGoods(inventory);
|
||||||
|
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*采购单退货
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping("/returnable")
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Result returnable() {
|
||||||
|
List<Integer> list = parmsUtil.getIntList("idList");
|
||||||
|
if (list == null || list.isEmpty()) {
|
||||||
|
return error("请选择要退货的商品");
|
||||||
|
}
|
||||||
|
inventoryPurchaseService.returnable(list);
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
package com.syjiaer.clinic.server.controller.inventory;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.syjiaer.clinic.server.common.constants.Constants;
|
||||||
|
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.inventory.InventorySupplier;
|
||||||
|
import com.syjiaer.clinic.server.entity.inventory.dto.SupplierQuery;
|
||||||
|
import com.syjiaer.clinic.server.service.inventory.InventorySupplierService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/inventory/supplier")
|
||||||
|
public class InventorySupplierController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private InventorySupplierService inventorySupplierService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询 供货商
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping("/list")
|
||||||
|
public Result<Page> list() {
|
||||||
|
SupplierQuery query= parmsUtil.getObject("query", SupplierQuery.class);
|
||||||
|
if (query == null){
|
||||||
|
return error("没有带查询条件");
|
||||||
|
}
|
||||||
|
QueryWrapper<InventorySupplier> queryWrapper = new QueryWrapper();
|
||||||
|
if(query.getTurn() != null){
|
||||||
|
queryWrapper.eq("turn",1);
|
||||||
|
}
|
||||||
|
if(query.getPageNum() == null || query.getPageNum() == 0){
|
||||||
|
query.setPageNum(1);
|
||||||
|
}
|
||||||
|
if (query.getPageSize() == null || query.getPageSize() == 0){
|
||||||
|
query.setPageSize(Constants.DetailPageSize);
|
||||||
|
}
|
||||||
|
return success(inventorySupplierService.listPage(query));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存供货商
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping("/save")
|
||||||
|
public Result save() {
|
||||||
|
InventorySupplier inventorySupplier = parmsUtil.getObject("inventorySupplier", InventorySupplier.class);
|
||||||
|
inventorySupplierService.saveOrUpdate(inventorySupplier);
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.syjiaer.clinic.server.entity.inventory.dto;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class ApplyOrderQuery {
|
||||||
|
private Integer pageNum;
|
||||||
|
private Integer pageSize;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.syjiaer.clinic.server.entity.inventory.dto;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class CheckQuery {
|
||||||
|
private Integer pageNum;
|
||||||
|
private Integer pageSize;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.syjiaer.clinic.server.entity.inventory.dto;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class PurchaseOrderQuery {
|
||||||
|
private Integer pageNum;
|
||||||
|
private Integer pageSize;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.syjiaer.clinic.server.entity.inventory.dto;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
public class SupplierQuery {
|
||||||
|
private Integer pageNum;
|
||||||
|
private Integer pageSize;
|
||||||
|
private Integer turn;
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.syjiaer.clinic.server.entity.inventory;
|
package com.syjiaer.clinic.server.entity.inventory.vo;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
|
|
@ -26,7 +26,7 @@ import java.time.LocalDateTime;
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@TableName("inventory_goods_view")
|
@TableName("inventory_goods_view")
|
||||||
@ApiModel(value = "InventoryGoodsView对象", description = "")
|
@ApiModel(value = "InventoryGoodsView对象", description = "")
|
||||||
public class InventoryGoodsView implements Serializable {
|
public class InventoryGoodsVo implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
package com.syjiaer.clinic.server.entity.inventory.vo;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author NiuZiYuan
|
||||||
|
* @since 2025-04-09
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@TableName("inventory_purchase_view")
|
||||||
|
@ApiModel(value = "InventoryPurchaseView对象", description = "")
|
||||||
|
public class InventoryPurchaseVo implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
private Integer managerUserId;
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private LocalDateTime purchaseDate;
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private LocalDateTime createDatetime;
|
||||||
|
|
||||||
|
private Integer supplierId;
|
||||||
|
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
private String shippingCode;
|
||||||
|
|
||||||
|
private String invoiceCode;
|
||||||
|
|
||||||
|
private Integer kindCount;
|
||||||
|
|
||||||
|
private BigDecimal totalPrice;
|
||||||
|
|
||||||
|
private String managerUserName;
|
||||||
|
|
||||||
|
private String supplierName;
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,11 @@ package com.syjiaer.clinic.server.mapper.inventory;
|
||||||
|
|
||||||
import com.syjiaer.clinic.server.entity.inventory.InventoryLog;
|
import com.syjiaer.clinic.server.entity.inventory.InventoryLog;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -14,5 +19,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
*/
|
*/
|
||||||
public interface InventoryLogMapper extends BaseMapper<InventoryLog> {
|
public interface InventoryLogMapper extends BaseMapper<InventoryLog> {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,8 +71,12 @@ public abstract class BaseService {
|
||||||
return managerUser;
|
return managerUser;
|
||||||
|
|
||||||
}
|
}
|
||||||
protected <T> Page<T> pageHelper(int pageNum, int pageSize, QueryWrapper<T> queryWrapper, BaseMapper<T> mapper){
|
protected <T> Page<T> pageHelper(int pageNum, int pageSize, QueryWrapper<T> queryWrapper, BaseMapper<T> mapper,String orderByStr ,boolean isAsc){
|
||||||
|
|
||||||
Long totalCount = mapper.selectCount(queryWrapper);
|
Long totalCount = mapper.selectCount(queryWrapper);
|
||||||
|
if (orderByStr == null || orderByStr.isEmpty()){
|
||||||
|
queryWrapper.orderBy(true,isAsc,orderByStr);
|
||||||
|
}
|
||||||
queryWrapper.last("LIMIT " + (pageNum - 1) * pageSize + ", " + pageSize);
|
queryWrapper.last("LIMIT " + (pageNum - 1) * pageSize + ", " + pageSize);
|
||||||
List<T> list = mapper.selectList(queryWrapper);
|
List<T> list = mapper.selectList(queryWrapper);
|
||||||
Page<T> page = new Page<>();
|
Page<T> page = new Page<>();
|
||||||
|
|
@ -81,6 +85,10 @@ public abstract class BaseService {
|
||||||
page.setTotal_page((int) Math.ceil(totalCount / (double) pageSize));
|
page.setTotal_page((int) Math.ceil(totalCount / (double) pageSize));
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
protected <T> Page<T> pageHelper(int pageNum, int pageSize, QueryWrapper<T> queryWrapper, BaseMapper<T> mapper){
|
||||||
|
return pageHelper(pageNum, pageSize, queryWrapper, mapper,null,true);
|
||||||
|
}
|
||||||
|
|
||||||
protected Map<String, Object> getParms() {
|
protected Map<String, Object> getParms() {
|
||||||
return parmsUtil.getMap();
|
return parmsUtil.getMap();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -342,4 +342,13 @@ public class GoodsService {
|
||||||
updateGoods.setInventoryFragmentNumber(totalFragmentNumber);
|
updateGoods.setInventoryFragmentNumber(totalFragmentNumber);
|
||||||
goodsMapper.updateById(updateGoods);
|
goodsMapper.updateById(updateGoods);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询goods
|
||||||
|
* @param goodsId 商品id
|
||||||
|
* @return 商品
|
||||||
|
*/
|
||||||
|
public Goods getById(int goodsId) {
|
||||||
|
return goodsMapper.selectById(goodsId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import com.syjiaer.clinic.server.common.vo.Result;
|
||||||
import com.syjiaer.clinic.server.entity.inventory.InventoryApply;
|
import com.syjiaer.clinic.server.entity.inventory.InventoryApply;
|
||||||
import com.syjiaer.clinic.server.entity.inventory.InventoryApplyLog;
|
import com.syjiaer.clinic.server.entity.inventory.InventoryApplyLog;
|
||||||
import com.syjiaer.clinic.server.entity.inventory.InventoryLog;
|
import com.syjiaer.clinic.server.entity.inventory.InventoryLog;
|
||||||
|
import com.syjiaer.clinic.server.entity.inventory.dto.ApplyOrderQuery;
|
||||||
import com.syjiaer.clinic.server.entity.manager.ManagerUser;
|
import com.syjiaer.clinic.server.entity.manager.ManagerUser;
|
||||||
import com.syjiaer.clinic.server.mapper.inventory.InventoryApplyLogMapper;
|
import com.syjiaer.clinic.server.mapper.inventory.InventoryApplyLogMapper;
|
||||||
import com.syjiaer.clinic.server.mapper.inventory.InventoryApplyMapper;
|
import com.syjiaer.clinic.server.mapper.inventory.InventoryApplyMapper;
|
||||||
|
|
@ -95,19 +96,11 @@ public class InventoryApplyService extends BaseService {
|
||||||
/**
|
/**
|
||||||
* 分页查询领用单
|
* 分页查询领用单
|
||||||
*/
|
*/
|
||||||
public Page<InventoryApply> list(int pageNum, int pageSize) {
|
public Page<InventoryApply> listPage(ApplyOrderQuery query) {
|
||||||
QueryWrapper<InventoryApply> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<InventoryApply> queryWrapper = new QueryWrapper<>();
|
||||||
long totalCount = inventoryApplyMapper.selectCount(queryWrapper);
|
|
||||||
int totalPage = (int) Math.ceil((double) totalCount / pageSize);
|
return pageHelper(query.getPageNum(), query.getPageSize(),
|
||||||
int offset = (pageNum - 1) * pageSize;
|
queryWrapper, inventoryApplyMapper, "create_datetime", false);
|
||||||
queryWrapper.orderByDesc("create_datetime");
|
|
||||||
queryWrapper.last("limit " + pageSize + " offset " + offset);
|
|
||||||
Page<InventoryApply> page = new Page<>();
|
|
||||||
page.setTotal_count(totalCount);
|
|
||||||
page.setTotal_page(totalPage);
|
|
||||||
List<InventoryApply> inventoryApplies = inventoryApplyMapper.selectList(queryWrapper);
|
|
||||||
page.setList(inventoryApplies);
|
|
||||||
return page;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import com.syjiaer.clinic.server.common.vo.Page;
|
||||||
import com.syjiaer.clinic.server.entity.inventory.InventoryCheck;
|
import com.syjiaer.clinic.server.entity.inventory.InventoryCheck;
|
||||||
import com.syjiaer.clinic.server.entity.inventory.InventoryCheckLog;
|
import com.syjiaer.clinic.server.entity.inventory.InventoryCheckLog;
|
||||||
import com.syjiaer.clinic.server.entity.inventory.InventoryLog;
|
import com.syjiaer.clinic.server.entity.inventory.InventoryLog;
|
||||||
|
import com.syjiaer.clinic.server.entity.inventory.dto.CheckQuery;
|
||||||
import com.syjiaer.clinic.server.entity.manager.ManagerUser;
|
import com.syjiaer.clinic.server.entity.manager.ManagerUser;
|
||||||
import com.syjiaer.clinic.server.mapper.inventory.InventoryCheckLogMapper;
|
import com.syjiaer.clinic.server.mapper.inventory.InventoryCheckLogMapper;
|
||||||
import com.syjiaer.clinic.server.mapper.inventory.InventoryCheckMapper;
|
import com.syjiaer.clinic.server.mapper.inventory.InventoryCheckMapper;
|
||||||
|
|
@ -33,19 +34,10 @@ public class InventoryCheckService extends BaseService {
|
||||||
private InventoryCheckMapper inventoryCheckMapper;
|
private InventoryCheckMapper inventoryCheckMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private InventoryCheckLogMapper inventoryCheckLogMapper;
|
private InventoryCheckLogMapper inventoryCheckLogMapper;
|
||||||
public Page<InventoryCheck> list(int pageNum, int pageSize) {
|
public Page<InventoryCheck> listPage(CheckQuery query) {
|
||||||
QueryWrapper<InventoryCheck> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<InventoryCheck> queryWrapper = new QueryWrapper<>();
|
||||||
long totalCount = inventoryCheckMapper.selectCount(queryWrapper);
|
return pageHelper(query.getPageNum(), query.getPageSize(),
|
||||||
int totalPage = (int) Math.ceil((double) totalCount / pageSize);
|
queryWrapper, inventoryCheckMapper, "create_datetime", false);
|
||||||
int offset = (pageNum - 1) * pageSize;
|
|
||||||
queryWrapper.orderByDesc("id");
|
|
||||||
queryWrapper.last("limit " + pageSize + " offset " + offset);
|
|
||||||
Page<InventoryCheck> page = new Page<>();
|
|
||||||
page.setTotal_count(totalCount);
|
|
||||||
page.setTotal_page(totalPage);
|
|
||||||
List<InventoryCheck> inventorySuppliers = inventoryCheckMapper.selectList(queryWrapper);
|
|
||||||
page.setList(inventorySuppliers);
|
|
||||||
return page;
|
|
||||||
}
|
}
|
||||||
@Transactional
|
@Transactional
|
||||||
public void save(List<Map> list, String remark) {
|
public void save(List<Map> list, String remark) {
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,16 @@ import com.syjiaer.clinic.server.common.vo.Page;
|
||||||
import com.syjiaer.clinic.server.common.vo.Result;
|
import com.syjiaer.clinic.server.common.vo.Result;
|
||||||
import com.syjiaer.clinic.server.entity.goods.Goods;
|
import com.syjiaer.clinic.server.entity.goods.Goods;
|
||||||
import com.syjiaer.clinic.server.entity.inventory.*;
|
import com.syjiaer.clinic.server.entity.inventory.*;
|
||||||
|
import com.syjiaer.clinic.server.entity.inventory.dto.PurchaseOrderQuery;
|
||||||
|
import com.syjiaer.clinic.server.entity.inventory.vo.InventoryGoodsVo;
|
||||||
|
import com.syjiaer.clinic.server.entity.inventory.vo.InventoryPurchaseVo;
|
||||||
|
import com.syjiaer.clinic.server.entity.manager.ManagerUser;
|
||||||
import com.syjiaer.clinic.server.mapper.goods.GoodsMapper;
|
import com.syjiaer.clinic.server.mapper.goods.GoodsMapper;
|
||||||
import com.syjiaer.clinic.server.mapper.inventory.*;
|
import com.syjiaer.clinic.server.mapper.inventory.*;
|
||||||
|
import com.syjiaer.clinic.server.mapper.manager.ManagerUserMapper;
|
||||||
|
import com.syjiaer.clinic.server.service.BaseService;
|
||||||
import com.syjiaer.clinic.server.service.goods.GoodsService;
|
import com.syjiaer.clinic.server.service.goods.GoodsService;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
@ -19,21 +26,22 @@ import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Date;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class InventoryPurchaseService {
|
public class InventoryPurchaseService extends BaseService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private GoodsMapper goodsMapper;
|
private GoodsMapper goodsMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private GoodsService goodsService;
|
private GoodsService goodsService;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private InventoryService inventoryService;
|
||||||
|
@Autowired
|
||||||
private InventoryMapper inventoryMapper;
|
private InventoryMapper inventoryMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private InventoryService inventoryService;
|
private ManagerUserMapper managerUserMapper;
|
||||||
|
@Autowired
|
||||||
|
private InventorySupplierMapper inventorySupplierMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private InventoryLogMapper inventoryLogMapper;
|
private InventoryLogMapper inventoryLogMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
@ -166,9 +174,10 @@ public class InventoryPurchaseService {
|
||||||
goodsService.updateInventoryInfoById(inventory.getGoodId());
|
goodsService.updateInventoryInfoById(inventory.getGoodId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* 创建采购订单
|
/**
|
||||||
* @param inventory 库存信息
|
* 已有采购单,添加新商品
|
||||||
|
* @param inventory 采购的商品
|
||||||
*/
|
*/
|
||||||
public void addOneGoods(Inventory inventory) {
|
public void addOneGoods(Inventory inventory) {
|
||||||
QueryWrapper<InventoryPurchase> orderWrapper = new QueryWrapper();
|
QueryWrapper<InventoryPurchase> orderWrapper = new QueryWrapper();
|
||||||
|
|
@ -251,4 +260,132 @@ public class InventoryPurchaseService {
|
||||||
goodsService.updateInventoryInfoById(inventory.getGoodId());
|
goodsService.updateInventoryInfoById(inventory.getGoodId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询采购单
|
||||||
|
* @param query 查询条件
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
|
||||||
|
public Page<InventoryPurchaseVo> listPage(PurchaseOrderQuery query) {
|
||||||
|
QueryWrapper<InventoryPurchase> queryWrapper = new QueryWrapper<>();
|
||||||
|
Page<InventoryPurchase> page = pageHelper(query.getPageNum(), query.getPageSize(),
|
||||||
|
queryWrapper, inventoryPurchaseMapper, "create_datetime", false);
|
||||||
|
List<InventoryPurchaseVo> voList = new ArrayList<>();
|
||||||
|
for (InventoryPurchase inventoryPurchase : page.getList()) {
|
||||||
|
InventoryPurchaseVo vo = new InventoryPurchaseVo();
|
||||||
|
BeanUtils.copyProperties(inventoryPurchase, vo);
|
||||||
|
vo.setManagerUserName(managerUserMapper.selectById(inventoryPurchase.getManagerUserId()).getName());
|
||||||
|
vo.setSupplierName(inventorySupplierMapper.selectById(inventoryPurchase.getSupplierId()).getName());
|
||||||
|
voList.add(vo);
|
||||||
|
}
|
||||||
|
Page<InventoryPurchaseVo> resultPage = new Page<>();
|
||||||
|
resultPage.setList(voList);
|
||||||
|
resultPage.setTotal_count(page.getTotal_count());
|
||||||
|
resultPage.setTotal_page(page.getTotal_page());
|
||||||
|
return resultPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取采购单详情信息
|
||||||
|
* @param code 采购单号
|
||||||
|
* @return inventoryOrderGoodsList 商品信息 inventoryOrder 采购单信息
|
||||||
|
*/
|
||||||
|
public Map<String, Object> getByCode(String code) {
|
||||||
|
QueryWrapper<Inventory> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("inventory_purchase_code", code);
|
||||||
|
queryWrapper.orderByAsc("id");
|
||||||
|
List<Inventory> list = inventoryMapper.selectList(queryWrapper);
|
||||||
|
List<InventoryGoodsVo> goodsVos = new ArrayList<>();
|
||||||
|
for (Inventory inventory : list){
|
||||||
|
InventoryGoodsVo goodsVo = new InventoryGoodsVo();
|
||||||
|
BeanUtils.copyProperties(inventory, goodsVo);
|
||||||
|
Goods goods = goodsMapper.selectById(inventory.getGoodId());
|
||||||
|
BeanUtils.copyProperties(goods, goodsVo);
|
||||||
|
goodsVos.add(goodsVo);
|
||||||
|
}
|
||||||
|
QueryWrapper<InventoryPurchase> purchaseQuery = new QueryWrapper();
|
||||||
|
purchaseQuery.eq("code", code);
|
||||||
|
InventoryPurchase inventoryPurchase = inventoryPurchaseMapper.selectOne(purchaseQuery);
|
||||||
|
InventoryPurchaseVo purchaseVo = new InventoryPurchaseVo();
|
||||||
|
BeanUtils.copyProperties(inventoryPurchase, purchaseVo);
|
||||||
|
purchaseVo.setManagerUserName(managerUserMapper.selectById(inventoryPurchase.getManagerUserId()).getName());
|
||||||
|
purchaseVo.setSupplierName(inventorySupplierMapper.selectById(inventoryPurchase.getSupplierId()).getName());
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("inventoryOrderGoodsList", goodsVos);
|
||||||
|
map.put("inventoryOrder", purchaseVo);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**.
|
||||||
|
* 更新采购单基本信息
|
||||||
|
* @param inventoryOrder 采购单信息
|
||||||
|
*/
|
||||||
|
public void updateById(InventoryPurchase inventoryOrder) {
|
||||||
|
InventoryPurchase updateOrder = new InventoryPurchase();
|
||||||
|
updateOrder.setCode(inventoryOrder.getCode());
|
||||||
|
updateOrder.setManagerUserId(inventoryOrder.getManagerUserId());
|
||||||
|
updateOrder.setSupplierId(inventoryOrder.getSupplierId());
|
||||||
|
updateOrder.setRemark(inventoryOrder.getRemark());
|
||||||
|
updateOrder.setPurchaseDate(inventoryOrder.getPurchaseDate());
|
||||||
|
updateOrder.setInvoiceCode(inventoryOrder.getInvoiceCode());
|
||||||
|
updateOrder.setShippingCode(inventoryOrder.getShippingCode());
|
||||||
|
inventoryPurchaseMapper.updateById(updateOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采购单中商品退货
|
||||||
|
* @param list inventory表idList
|
||||||
|
*/
|
||||||
|
public void returnable(List<Integer> list) {
|
||||||
|
|
||||||
|
ManagerUser user = getManagerUser();
|
||||||
|
|
||||||
|
String orderCode = null;
|
||||||
|
for (Integer id : list) {
|
||||||
|
Inventory inventory = inventoryMapper.selectById(id);
|
||||||
|
if (inventory == null) {
|
||||||
|
throw new MessageException("找不到库存信息");
|
||||||
|
}
|
||||||
|
orderCode = inventory.getInventoryPurchaseCode();
|
||||||
|
InventoryLog log = inventoryService.adjustNumber(id,
|
||||||
|
0, inventory.getFragmentNumber(), "退货");
|
||||||
|
if (log.getChangeWholeNumber() < 0) {
|
||||||
|
|
||||||
|
log.setType(InventoryTypeEnum.RETURN_OUT.getType());
|
||||||
|
log.setSocialType(InventorySocialTypeEnum.OTHER_OUTBOUND.getType());
|
||||||
|
log.setOperateId(user.getId());
|
||||||
|
log.setOperateName(user.getName());
|
||||||
|
inventoryLogMapper.insert(log);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
throw new MessageException("退货不能增加库存");
|
||||||
|
|
||||||
|
}
|
||||||
|
//记录日志
|
||||||
|
InventoryPurchaseLog inventoryPurchaseLog = new InventoryPurchaseLog();
|
||||||
|
inventoryPurchaseLog.setNumber(log.getChangeWholeNumber());
|
||||||
|
inventoryPurchaseLog.setInventoryPurchaseCode(orderCode);
|
||||||
|
inventoryPurchaseLog.setSocialType(InventorySocialTypeEnum.OTHER_OUTBOUND.getType());
|
||||||
|
inventoryPurchaseLog.setInventoryId(id);
|
||||||
|
inventoryPurchaseLog.setUploadStatus(UploadStatusEnum.NoUpload.getStatus());
|
||||||
|
inventoryPurchaseLogMapper.insert(inventoryPurchaseLog);
|
||||||
|
}
|
||||||
|
|
||||||
|
//更新订单总价
|
||||||
|
QueryWrapper<Inventory> queryGoods = new QueryWrapper<>();
|
||||||
|
queryGoods.eq("inventory_purchase_code", orderCode);
|
||||||
|
List<Inventory> goodsList = inventoryMapper.selectList(queryGoods);
|
||||||
|
final BigDecimal[] totalPrice = {new BigDecimal(0)};
|
||||||
|
if (!goodsList.isEmpty()) {
|
||||||
|
goodsList.forEach(inventoryGoods -> {
|
||||||
|
BigDecimal multiply = inventoryGoods.getPurchaseUnitPrice().multiply(new BigDecimal(inventoryGoods.getWholeNumber()));
|
||||||
|
totalPrice[0] = totalPrice[0].add(multiply);
|
||||||
|
});
|
||||||
|
UpdateWrapper<InventoryPurchase> updateOrder = new UpdateWrapper();
|
||||||
|
updateOrder.set("total_price", totalPrice[0]);
|
||||||
|
updateOrder.eq("code", orderCode);
|
||||||
|
inventoryPurchaseMapper.update(null, updateOrder);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -112,11 +112,10 @@ public class InventoryService extends BaseService {
|
||||||
* 根据goodsId 获取该goods的所有库存信息
|
* 根据goodsId 获取该goods的所有库存信息
|
||||||
*/
|
*/
|
||||||
public List<Inventory> getListByGoodsId(int goodsId) {
|
public List<Inventory> getListByGoodsId(int goodsId) {
|
||||||
Goods goods = goodsMapper.selectById(goodsId);
|
QueryWrapper<Inventory> queryWrapper = new QueryWrapper<>();
|
||||||
if (goods == null) {
|
queryWrapper.eq("good_id", goodsId);
|
||||||
throw new MessageException("商品不存在");
|
queryWrapper.orderByDesc("create_datetime");
|
||||||
}
|
return inventoryMapper.selectList(queryWrapper);
|
||||||
return inventoryMapper.selectList(new QueryWrapper<Inventory>().eq("good_id", goodsId).orderByDesc("create_datetime"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -231,6 +230,21 @@ public class InventoryService extends BaseService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Inventory> listByPurchaseCode(String puerchCode) {
|
||||||
|
QueryWrapper<Inventory> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("inventory_purchase_code", puerchCode);
|
||||||
|
return inventoryMapper.selectList(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Map<String, Object>> getInventoryLogByGoodsId(int goodsId, LocalDateTime startDateTime, LocalDateTime endDateTime) {
|
||||||
|
QueryWrapper<InventoryLog> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("goods_id", goodsId);
|
||||||
|
queryWrapper.between("create_time", startDateTime, endDateTime);
|
||||||
|
return inventoryLogMapper.selectMaps(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
|
|
@ -255,7 +269,7 @@ public class InventoryService extends BaseService {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void update(List<Inventory> list) {
|
public void updatePurchaseItem(List<Inventory> list) {
|
||||||
ManagerUser user = getManagerUser();
|
ManagerUser user = getManagerUser();
|
||||||
if (list == null || list.isEmpty()) {
|
if (list == null || list.isEmpty()) {
|
||||||
throw new MessageException("没有修改的数据");
|
throw new MessageException("没有修改的数据");
|
||||||
|
|
@ -529,4 +543,6 @@ public class InventoryService extends BaseService {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.syjiaer.clinic.server.service.inventory;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.syjiaer.clinic.server.common.vo.Page;
|
||||||
|
import com.syjiaer.clinic.server.entity.inventory.InventorySupplier;
|
||||||
|
import com.syjiaer.clinic.server.entity.inventory.dto.SupplierQuery;
|
||||||
|
import com.syjiaer.clinic.server.mapper.inventory.InventorySupplierMapper;
|
||||||
|
import com.syjiaer.clinic.server.service.BaseService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class InventorySupplierService extends BaseService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private InventorySupplierMapper inventorySupplierMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 供货商分页查询
|
||||||
|
* @param query
|
||||||
|
*/
|
||||||
|
public Page<InventorySupplier> listPage(SupplierQuery query) {
|
||||||
|
QueryWrapper<InventorySupplier> queryWrapper = new QueryWrapper<>();
|
||||||
|
if(query.getTurn() != null){
|
||||||
|
queryWrapper.eq("turn",1);
|
||||||
|
}
|
||||||
|
return pageHelper(query.getPageNum(), query.getPageSize(),
|
||||||
|
queryWrapper, inventorySupplierMapper, "id", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存供货商信息
|
||||||
|
* @param inventorySupplier
|
||||||
|
*/
|
||||||
|
public void saveOrUpdate(InventorySupplier inventorySupplier) {
|
||||||
|
inventorySupplierMapper.insertOrUpdate(inventorySupplier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
package com.syjiaer.clinic.server.service.medical;
|
package com.syjiaer.clinic.server.service.medical;
|
||||||
|
|
||||||
import com.syjiaer.clinic.server.common.enums.MedicalRecordDetailTypeEnum;
|
import com.syjiaer.clinic.server.common.enums.MedicalRecordDetailTypeEnum;
|
||||||
|
import com.syjiaer.clinic.server.entity.goods.Goods;
|
||||||
import com.syjiaer.clinic.server.entity.item.Item;
|
import com.syjiaer.clinic.server.entity.item.Item;
|
||||||
import com.syjiaer.clinic.server.entity.medical.MedicalRecord;
|
import com.syjiaer.clinic.server.entity.medical.MedicalRecord;
|
||||||
import com.syjiaer.clinic.server.entity.medical.MedicalRecordDetail;
|
import com.syjiaer.clinic.server.entity.medical.MedicalRecordDetail;
|
||||||
import com.syjiaer.clinic.server.entity.medical.dto.MedicalRecordSaveDto;
|
import com.syjiaer.clinic.server.entity.medical.dto.MedicalRecordSaveDto;
|
||||||
|
import com.syjiaer.clinic.server.mapper.goods.GoodsMapper;
|
||||||
import com.syjiaer.clinic.server.mapper.item.ItemMapper;
|
import com.syjiaer.clinic.server.mapper.item.ItemMapper;
|
||||||
import com.syjiaer.clinic.server.mapper.medical.MedicalRecordDetailMapper;
|
import com.syjiaer.clinic.server.mapper.medical.MedicalRecordDetailMapper;
|
||||||
import com.syjiaer.clinic.server.mapper.medical.MedicalRecordMapper;
|
import com.syjiaer.clinic.server.mapper.medical.MedicalRecordMapper;
|
||||||
|
|
@ -21,6 +23,8 @@ public class MedicalRecordService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ItemMapper itemMapper;
|
private ItemMapper itemMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private GoodsMapper goodsMapper;
|
||||||
|
@Autowired
|
||||||
private MedicalRecordMapper medicalRecordMapper;
|
private MedicalRecordMapper medicalRecordMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private MedicalRecordDetailMapper medicalRecordDetailMapper;
|
private MedicalRecordDetailMapper medicalRecordDetailMapper;
|
||||||
|
|
@ -44,7 +48,7 @@ public class MedicalRecordService {
|
||||||
detailList.add(detail);
|
detailList.add(detail);
|
||||||
}
|
}
|
||||||
for (Map.Entry<Integer,Integer> itemMap : saveDto.getGoodsMap().entrySet()){
|
for (Map.Entry<Integer,Integer> itemMap : saveDto.getGoodsMap().entrySet()){
|
||||||
Goods dbGoods = iGoodsService.getById(itemMap.getKey());
|
Goods dbGoods = goodsMapper.selectById(itemMap.getKey());
|
||||||
MedicalRecordDetail detail = new MedicalRecordDetail();
|
MedicalRecordDetail detail = new MedicalRecordDetail();
|
||||||
detail.setProjectId(itemMap.getKey());
|
detail.setProjectId(itemMap.getKey());
|
||||||
detail.setProjectName(dbGoods.getName());
|
detail.setProjectName(dbGoods.getName());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue