|
|
@@ -609,8 +609,10 @@
|
|
609
|
609
|
drugSpecificationUnit,
|
|
610
|
610
|
<!-- sum(to_number(ruku)) ruCount,
|
|
611
|
611
|
sum(to_number(chuku)) chuCount -->
|
|
612
|
|
- case when nvl(sum(to_number(ruku)), '')='' then 0 else sum(to_number(ruku)) end ruCount,
|
|
613
|
|
- case when nvl(sum(to_number(chuku)),'')='' then 0 else sum(to_number(chuku)) end chuCount
|
|
|
612
|
+ <!-- case when NVL(sum(to_number(ruku)), '')='' then 0 else sum(to_number(ruku)) end ruCount,
|
|
|
613
|
+ case when NVL(sum(to_number(chuku)),'')='' then 0 else sum(to_number(chuku)) end chuCount -->
|
|
|
614
|
+ case when IFNULL(sum(CAST(ruku AS UNSIGNED)), '')='' then 0 else sum(CAST(ruku AS UNSIGNED)) end ruCount,
|
|
|
615
|
+ case when IFNULL(sum(CAST(chuku AS UNSIGNED)),'')='' then 0 else sum(CAST(chuku AS UNSIGNED)) end chuCount
|
|
614
|
616
|
FROM
|
|
615
|
617
|
(
|
|
616
|
618
|
SELECT
|
|
|
@@ -618,10 +620,10 @@
|
|
618
|
620
|
drug_name drugName,
|
|
619
|
621
|
drug_specification_unit drugSpecificationUnit,
|
|
620
|
622
|
drug_specification drug_specification,
|
|
621
|
|
- sum(to_number(storage_count)) storage_count,
|
|
622
|
|
- sum(to_number(delivery_count)) deliveryCount,
|
|
623
|
|
- (sum(to_number(storage_count))) * drug_specification ruku,
|
|
624
|
|
- (sum(to_number(delivery_count))) * drug_specification chuku
|
|
|
623
|
+ sum(CAST(storage_count AS UNSIGNED)) storage_count,
|
|
|
624
|
+ sum(CAST(delivery_count AS UNSIGNED)) deliveryCount,
|
|
|
625
|
+ (sum(CAST(storage_count AS UNSIGNED))) * drug_specification ruku,
|
|
|
626
|
+ (sum(CAST(delivery_count AS UNSIGNED))) * drug_specification chuku
|
|
625
|
627
|
FROM
|
|
626
|
628
|
business_drug_standing_book
|
|
627
|
629
|
where 1=1
|
|
|
@@ -712,15 +714,15 @@
|
|
712
|
714
|
AND is_last_shelf_data = 1
|
|
713
|
715
|
)a -->
|
|
714
|
716
|
|
|
715
|
|
- select abs((rk-ck))everyQkucun
|
|
|
717
|
+ <!-- select abs((rk-ck))everyQkucun
|
|
716
|
718
|
from (
|
|
717
|
719
|
select
|
|
718
|
|
- case when nvl(sum(to_number(rukuCount)), '')='' then 0 else sum(to_number(rukuCount)) end rk,
|
|
719
|
|
- case when nvl(sum(to_number(cukuCount)), '')='' then 0 else sum(to_number(cukuCount)) end ck
|
|
|
720
|
+ case when IFNULL(sum(CAST(rukuCount AS UNSIGNED)), '')='' then 0 else sum(CAST(rukuCount AS UNSIGNED)) end rk,
|
|
|
721
|
+ case when IFNULL(sum(CAST(cukuCount AS UNSIGNED)), '')='' then 0 else sum(CAST(cukuCount AS UNSIGNED)) end ck
|
|
720
|
722
|
from (
|
|
721
|
723
|
SELECT
|
|
722
|
|
- to_number(storage_count) * to_number(drug_specification) rukuCount,
|
|
723
|
|
- to_number(delivery_count) * to_number(drug_specification) cukuCount
|
|
|
724
|
+ CAST(storage_count AS UNSIGNED) * CAST(drug_specification AS UNSIGNED) rukuCount,
|
|
|
725
|
+ CAST(delivery_count AS UNSIGNED) * CAST(drug_specification AS UNSIGNED) cukuCount
|
|
724
|
726
|
FROM
|
|
725
|
727
|
business_drug_standing_book
|
|
726
|
728
|
WHERE
|
|
|
@@ -732,7 +734,28 @@
|
|
732
|
734
|
AND create_time < to_date(#{startDate},'yyyy-mm-dd hh24:mi:ss')
|
|
733
|
735
|
|
|
734
|
736
|
)
|
|
735
|
|
- )
|
|
|
737
|
+ ) -->
|
|
|
738
|
+
|
|
|
739
|
+ select abs((b.rk-b.ck))everyQkucun
|
|
|
740
|
+ from (
|
|
|
741
|
+ select
|
|
|
742
|
+ case when IFNULL(sum(CAST(a.rukuCount AS UNSIGNED)), '')='' then 0 else sum(CAST(a.rukuCount AS UNSIGNED)) end rk,
|
|
|
743
|
+ case when IFNULL(sum(CAST(a.cukuCount AS UNSIGNED)), '')='' then 0 else sum(CAST(a.cukuCount AS UNSIGNED)) end ck
|
|
|
744
|
+ from (
|
|
|
745
|
+ SELECT
|
|
|
746
|
+ CAST(storage_count AS UNSIGNED) * CAST(drug_specification AS UNSIGNED) rukuCount,
|
|
|
747
|
+ CAST(delivery_count AS UNSIGNED) * CAST(drug_specification AS UNSIGNED) cukuCount
|
|
|
748
|
+ FROM
|
|
|
749
|
+ business_drug_standing_book
|
|
|
750
|
+ WHERE
|
|
|
751
|
+ org_id = #{org_id}
|
|
|
752
|
+ AND drug_kind = #{drug_kind}
|
|
|
753
|
+ AND drug_name = #{drug_name}
|
|
|
754
|
+ AND drug_specification = #{drug_specification}
|
|
|
755
|
+ AND drug_specification_unit = #{drug_specification_unit}
|
|
|
756
|
+ AND create_time < to_date(#{startDate},'yyyy-mm-dd hh24:mi:ss')
|
|
|
757
|
+ )a
|
|
|
758
|
+ )b
|
|
736
|
759
|
|
|
737
|
760
|
|
|
738
|
761
|
|
|
|
@@ -772,7 +795,7 @@
|
|
772
|
795
|
ORDER BY
|
|
773
|
796
|
drugKind,
|
|
774
|
797
|
drugName -->
|
|
775
|
|
- select
|
|
|
798
|
+ <!-- select
|
|
776
|
799
|
drugKind,
|
|
777
|
800
|
drugName,
|
|
778
|
801
|
drugSpecificationUnit,
|
|
|
@@ -815,6 +838,55 @@
|
|
815
|
838
|
) bb
|
|
816
|
839
|
ORDER BY
|
|
817
|
840
|
drugKind,
|
|
|
841
|
+ drugName -->
|
|
|
842
|
+
|
|
|
843
|
+
|
|
|
844
|
+
|
|
|
845
|
+
|
|
|
846
|
+
|
|
|
847
|
+select
|
|
|
848
|
+ drugKind,
|
|
|
849
|
+ drugName,
|
|
|
850
|
+ drugSpecificationUnit,
|
|
|
851
|
+ abs((rk-ck)) endAmount
|
|
|
852
|
+ from (
|
|
|
853
|
+ SELECT
|
|
|
854
|
+ drug_kind drugKind,
|
|
|
855
|
+ drug_name drugName,
|
|
|
856
|
+ drug_specification_unit drugSpecificationUnit,
|
|
|
857
|
+ case when IFNULL(sum(CAST(rukuCount AS UNSIGNED)), '')='' then 0 else sum(CAST(rukuCount AS UNSIGNED)) end rk,
|
|
|
858
|
+ case when IFNULL(sum(CAST(cukuCount AS UNSIGNED)), '')='' then 0 else sum(CAST(cukuCount AS UNSIGNED)) end ck
|
|
|
859
|
+ FROM
|
|
|
860
|
+ (
|
|
|
861
|
+ select
|
|
|
862
|
+ drug_kind,
|
|
|
863
|
+ drug_name,
|
|
|
864
|
+ drug_specification_unit,
|
|
|
865
|
+ drug_specification,
|
|
|
866
|
+ CAST(storage_count AS UNSIGNED) * CAST(drug_specification AS UNSIGNED) rukuCount,
|
|
|
867
|
+ CAST(delivery_count AS UNSIGNED) * CAST(drug_specification AS UNSIGNED) cukuCount
|
|
|
868
|
+ FROM
|
|
|
869
|
+ business_drug_standing_book
|
|
|
870
|
+ WHERE
|
|
|
871
|
+ 1=1
|
|
|
872
|
+ <if test="orgId != null">
|
|
|
873
|
+ and org_id = #{orgId}
|
|
|
874
|
+ </if>
|
|
|
875
|
+ <if test="endDate !=null">
|
|
|
876
|
+ and create_time <= to_date(#{endDate},'yyyy-mm-dd hh24:mi:ss')
|
|
|
877
|
+ </if>
|
|
|
878
|
+ order by create_time desc
|
|
|
879
|
+ ) a
|
|
|
880
|
+ GROUP BY
|
|
|
881
|
+ drug_kind,
|
|
|
882
|
+ drug_name,
|
|
|
883
|
+ drug_specification_unit
|
|
|
884
|
+ ORDER BY
|
|
|
885
|
+ drugKind,
|
|
|
886
|
+ drugName
|
|
|
887
|
+ ) bb
|
|
|
888
|
+ ORDER BY
|
|
|
889
|
+ drugKind,
|
|
818
|
890
|
drugName
|
|
819
|
891
|
</select>
|
|
820
|
892
|
|