|
@@ -0,0 +1,94 @@
|
|
|
+package vip.xiaonuo.quality.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import vip.xiaonuo.common.pojo.CommonResult;
|
|
|
+import vip.xiaonuo.quality.entity.QualityReagentInStock;
|
|
|
+import vip.xiaonuo.quality.entity.QualityReagentStock;
|
|
|
+import vip.xiaonuo.quality.mapper.QualityReagentInStockMapper;
|
|
|
+import vip.xiaonuo.quality.mapper.QualityReagentStockMapper;
|
|
|
+import vip.xiaonuo.quality.param.QualityStockPageParam;
|
|
|
+import vip.xiaonuo.quality.service.IQualityReagentInStockService;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.text.DecimalFormat;
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 质量试剂入库 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author author
|
|
|
+ * @since 2025-03-10
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class QualityReagentInStockServiceImpl extends ServiceImpl<QualityReagentInStockMapper, QualityReagentInStock> implements IQualityReagentInStockService {
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private QualityReagentInStockMapper inStockMapper;
|
|
|
+ @Autowired
|
|
|
+ private QualityReagentStockMapper stockMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CommonResult add(QualityReagentInStock inStock) {
|
|
|
+ if ("".equals(inStock.getOrgId()) || null == inStock.getOrgId()) {
|
|
|
+ return CommonResult.error();
|
|
|
+ } else {
|
|
|
+ inStockMapper.insert(inStock);
|
|
|
+ QueryWrapper<QualityReagentStock> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("org_id", inStock.getOrgId()).eq("reagent", inStock.getReagent());
|
|
|
+ QualityReagentStock stock = stockMapper.selectOne(queryWrapper);
|
|
|
+ if (ObjectUtil.isEmpty(stock)) {
|
|
|
+ QualityReagentStock stock1 = new QualityReagentStock();
|
|
|
+ stock1.setOrgId(inStock.getOrgId());
|
|
|
+ stock1.setOrgName(inStock.getOrgName());
|
|
|
+ stock1.setReagent(inStock.getReagent());
|
|
|
+ stock1.setStock(inStock.getInValue());
|
|
|
+ stockMapper.insert(stock1);
|
|
|
+ } else {
|
|
|
+ String stockStock = stock.getStock();
|
|
|
+ Double aDouble = Double.valueOf(stockStock);
|
|
|
+ String inValue = inStock.getInValue();
|
|
|
+ Double aDouble1 = Double.valueOf(inValue);
|
|
|
+ DecimalFormat def = new DecimalFormat("0.00");
|
|
|
+ stock.setStock(def.format(aDouble + aDouble1));
|
|
|
+ stockMapper.updateById(stock);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return CommonResult.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CommonResult edit(QualityReagentInStock inStock) {
|
|
|
+ QualityReagentInStock inStock1 = inStockMapper.selectById(inStock);
|
|
|
+ QueryWrapper<QualityReagentStock> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("org_id", inStock.getOrgId()).eq("reagent", inStock.getReagent());
|
|
|
+ QualityReagentStock stock = stockMapper.selectOne(queryWrapper);
|
|
|
+ Double aDouble = Double.valueOf(stock.getStock());
|
|
|
+ Double aDouble1 = Double.valueOf(inStock1.getInValue());
|
|
|
+ Double aDouble2 = Double.valueOf(inStock.getInValue());
|
|
|
+ DecimalFormat def = new DecimalFormat("0.00");
|
|
|
+ stock.setStock(def.format(aDouble - aDouble1+aDouble2));
|
|
|
+ stockMapper.updateById(stock);
|
|
|
+ inStockMapper.updateById(inStock);
|
|
|
+ return CommonResult.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<QualityReagentInStock> page(QualityStockPageParam pageParam) {
|
|
|
+ Integer pageSize = pageParam.getPageSize();
|
|
|
+ Integer pageNum = pageParam.getPageNum();
|
|
|
+ String orgId = pageParam.getOrgId();
|
|
|
+ QueryWrapper<QualityReagentInStock> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq(StringUtils.isNotBlank(orgId), "org_id", orgId);
|
|
|
+ queryWrapper.orderByDesc("create_time");
|
|
|
+ Page<QualityReagentInStock> page = new Page<>(pageNum, pageSize);
|
|
|
+ return inStockMapper.selectPage(page,queryWrapper);
|
|
|
+ }
|
|
|
+}
|