Commit 8dbe3e15 by zhu.zewen

修复药品数据统计

parent 2b37ca2a
......@@ -32,7 +32,7 @@ public class PhysicAmpoule extends BaseVersionEntity {
@ApiModelProperty(value = "药品数量")
private Integer physicNum;
@ApiModelProperty(value = "类型")
@ApiModelProperty(value = "类型:1-接收、2-退回")
private Integer type;
@ApiModelProperty(value = "订单号")
private String orderNo;
......
......@@ -29,6 +29,6 @@ public class PhysicDestroyCheckDetail extends BaseVersionEntity {
@ApiModelProperty(value = "批号")
private String batchNo;
@ApiModelProperty(value = "药品数量")
private Integer physicNum;
@ApiModelProperty(value = "销毁数量")
private Integer destroyNum;
}
......@@ -17,7 +17,6 @@ import com.jmai.physic.service.PhysicAmpouleService;
import com.jmai.physic.service.PhysicBillService;
import com.jmai.physic.vo.PhysicAmpouleUseVO;
import com.jmai.physic.vo.PhysicAmpouleVO;
import com.jmai.physic.vo.PhysicAmpouleVO;
import com.jmai.physic.vo.PhysicVO;
import com.jmai.sys.AbstractService;
import com.jmai.sys.consts.enums.RoleTypeEum;
......
......@@ -70,7 +70,7 @@ public class PhysicDestroyCheckServiceImpl extends BaseServiceImpl<PhysicDestroy
@Override
public void create(PhysicDestroyCheckCreateReq req) {
String orderNo = sysManager.newOrderNo(PhysicDestroyCheck.class);
int destroyNum = req.getCheckDetailList().stream().mapToInt(PhysicDestroyCheckDetail::getPhysicNum).sum();
int destroyNum = req.getCheckDetailList().stream().mapToInt(PhysicDestroyCheckDetail::getDestroyNum).sum();
PhysicDestroyCheck check = new PhysicDestroyCheck();
BeanUtil.copyProperties(req, check);
......@@ -188,12 +188,12 @@ public class PhysicDestroyCheckServiceImpl extends BaseServiceImpl<PhysicDestroy
ampoule.setExpireDate(physicDestroyCheckDetail.getExpireDate());
ampoule.setBatchNo(ampoule.getBatchNo());
ampoule.setPhysicNum(physicDestroyCheckDetail.getPhysicNum());
ampoule.setPhysicNum(physicDestroyCheckDetail.getDestroyNum());
ampoule.setOrderNo(physicDestroyCheck.getOrderNo());
ampoule.setTransferDeptId(physicDestroyCheck.getApplyDeptId());
ampoule.setAcceptDeptId(sysUser.getDeptId());
ampoule.setExpendNum(physicDestroyCheckDetail.getPhysicNum());
ampoule.setExpendNum(physicDestroyCheckDetail.getDestroyNum());
ampoule.setRecycleReceiptNum(null);
ampoule.setType(2);
......@@ -201,8 +201,8 @@ public class PhysicDestroyCheckServiceImpl extends BaseServiceImpl<PhysicDestroy
Integer batchNoSum = physicStorageAmpouleMapper.selectCurrentSumByBatchNo(physicDestroyCheckDetail.getPhysicName(), physicDestroyCheckDetail.getPhysicSpec(), physicDestroyCheckDetail.getFactoryName(), physicDestroyCheckDetail.getBatchNo());
Integer physicSum = physicStorageAmpouleMapper.selectCurrentSumByName(physicDestroyCheckDetail.getPhysicName(), physicDestroyCheckDetail.getPhysicSpec(), physicDestroyCheckDetail.getFactoryName());
ampoule.setBatchBalance(batchNoSum - physicDestroyCheckDetail.getPhysicNum());
ampoule.setPhysicBalance(physicSum - physicDestroyCheckDetail.getPhysicNum());
ampoule.setBatchBalance(batchNoSum - physicDestroyCheckDetail.getDestroyNum());
ampoule.setPhysicBalance(physicSum - physicDestroyCheckDetail.getDestroyNum());
physicStorageAmpouleMapper.insert(ampoule);
}
}
......
......@@ -33,12 +33,23 @@
</select>
<select id="selectCurrentSumByBatchNo" resultType="java.lang.Integer">
select IFNULL(sum(physic_num),0) from physic_ampoule where
physic_name=#{name} and physic_spec=#{spec} and batch_no=#{batchNo} and factory_name =#{factoryName}
SELECT
IFNULL(SUM(CASE WHEN type = 1 THEN physic_num WHEN type = 2 THEN -physic_num ELSE 0 END), 0)
FROM physic_ampoule
WHERE status=100
AND physic_name=#{name}
AND physic_spec=#{spec}
AND factory_name =#{factoryName}
AND batch_no=#{batchNo}
</select>
<select id="selectCurrentSumByName" resultType="java.lang.Integer">
select IFNULL(sum(physic_num),0) from physic_ampoule where
physic_name=#{name} and physic_spec=#{spec} and factory_name =#{factoryName}
SELECT
IFNULL(SUM(CASE WHEN type = 1 THEN physic_num WHEN type = 2 THEN -physic_num ELSE 0 END), 0)
FROM physic_ampoule
WHERE status=100
AND physic_name=#{name}
AND physic_spec=#{spec}
AND factory_name =#{factoryName}
</select>
</mapper>
......@@ -23,13 +23,23 @@
</select>
<select id="selectCurrentSumByBatchNo" resultType="java.lang.Integer">
select (IFNULL(sum(acquire_num),0) - IFNULL(sum(expend_num),0)) from physic_storage_ampoule where
physic_name=#{name} and physic_spec=#{spec} and batch_no=#{batchNo} and factory_name =#{factoryName}
SELECT
IFNULL(SUM(CASE WHEN type = 1 THEN physic_num WHEN type = 2 THEN -physic_num ELSE 0 END), 0)
FROM physic_storage_ampoule
WHERE status=100
AND physic_name=#{name}
AND physic_spec=#{spec}
AND factory_name =#{factoryName}
AND batch_no=#{batchNo}
</select>
<select id="selectCurrentSumByName" resultType="java.lang.Integer">
select (IFNULL(sum(acquire_num),0) - IFNULL(sum(expend_num),0)) from physic_storage_ampoule where
physic_name=#{name} and physic_spec=#{spec} and factory_name =#{factoryName}
SELECT
IFNULL(SUM(CASE WHEN type = 1 THEN physic_num WHEN type = 2 THEN -physic_num ELSE 0 END), 0)
FROM physic_storage_ampoule
WHERE status=100
AND physic_name=#{name}
AND physic_spec=#{spec}
AND factory_name =#{factoryName}
</select>
<select id="selectDestroy" resultType="com.jmai.physic.vo.PhysicDestroyNumVO">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment