Kaynağa Gözat

分包合同合同额计算修改

lamphua 1 ay önce
ebeveyn
işleme
59c2286399

+ 2
- 2
oa-back/ruoyi-admin/src/main/java/com/ruoyi/web/controller/oa/CmcSubContractController.java Dosyayı Görüntüle

@@ -322,7 +322,7 @@ public class CmcSubContractController extends BaseController
322 322
         cmcSubContract.setProjectSource("1");
323 323
         List<CmcSubContract> sourceList;
324 324
         if (beginTime.equals(""))
325
-            sourceList = cmcSubContractService.selectCmcSubContractList(cmcSubContract);
325
+            sourceList = cmcSubContractService.selectCmcSubContractListP(cmcSubContract);
326 326
         else {
327 327
             Map<String, Object> params = new HashMap<>();
328 328
             params.put("beginTime", beginTime + " 00:00:00");
@@ -351,7 +351,7 @@ public class CmcSubContractController extends BaseController
351 351
         paidSourceAmountObject.put("院外项目付款金额", paidWAmount);
352 352
         cmcSubContract.setProjectSource("0");
353 353
         if (beginTime.equals(""))
354
-            sourceList = cmcSubContractService.selectCmcSubContractList(cmcSubContract);
354
+            sourceList = cmcSubContractService.selectCmcSubContractListP(cmcSubContract);
355 355
         else {
356 356
             Map<String, Object> params = new HashMap<>();
357 357
             params.put("beginTime", beginTime + " 00:00:00");

+ 8
- 0
oa-back/ruoyi-system/src/main/java/com/ruoyi/oa/mapper/CmcSubContractMapper.java Dosyayı Görüntüle

@@ -29,6 +29,14 @@ public interface CmcSubContractMapper
29 29
      */
30 30
     public List<CmcSubContract> selectCmcSubContractList(CmcSubContract cmcSubContract);
31 31
 
32
+    /**
33
+     * 关联项目查询cmc分包合同评审列表
34
+     *
35
+     * @param cmcSubContract cmc分包合同评审
36
+     * @return cmc分包合同评审集合
37
+     */
38
+    public List<CmcSubContract> selectCmcSubContractListP(CmcSubContract cmcSubContract);
39
+
32 40
     /**
33 41
      * 按时间范围查询cmc分包合同评审列表
34 42
      *

+ 8
- 0
oa-back/ruoyi-system/src/main/java/com/ruoyi/oa/service/ICmcSubContractService.java Dosyayı Görüntüle

@@ -27,6 +27,14 @@ public interface ICmcSubContractService
27 27
      */
28 28
     public List<CmcSubContract> selectCmcSubContractList(CmcSubContract cmcSubContract);
29 29
 
30
+    /**
31
+     * 关联项目查询cmc分包合同评审列表
32
+     *
33
+     * @param cmcSubContract cmc分包合同评审
34
+     * @return cmc分包合同评审集合
35
+     */
36
+    public List<CmcSubContract> selectCmcSubContractListP(CmcSubContract cmcSubContract);
37
+
30 38
     /**
31 39
      * 按时间范围查询cmc分包合同评审列表
32 40
      *

+ 12
- 0
oa-back/ruoyi-system/src/main/java/com/ruoyi/oa/service/impl/CmcSubContractServiceImpl.java Dosyayı Görüntüle

@@ -43,6 +43,18 @@ public class CmcSubContractServiceImpl implements ICmcSubContractService
43 43
         return cmcSubContractMapper.selectCmcSubContractList(cmcSubContract);
44 44
     }
45 45
 
46
+    /**
47
+     * 关联项目查询cmc分包合同评审列表
48
+     *
49
+     * @param cmcSubContract cmc分包合同评审
50
+     * @return cmc分包合同评审
51
+     */
52
+    @Override
53
+    public List<CmcSubContract> selectCmcSubContractListP(CmcSubContract cmcSubContract)
54
+    {
55
+        return cmcSubContractMapper.selectCmcSubContractListP(cmcSubContract);
56
+    }
57
+
46 58
     /**
47 59
      * 按时间范围查询cmc分包合同评审列表
48 60
      *

+ 45
- 45
oa-back/ruoyi-system/src/main/resources/mapper/oa/CmcContractMapper.xml Dosyayı Görüntüle

@@ -110,9 +110,6 @@
110 110
             <if test="signRemark != null  and signRemark != ''"> and c.sign_remark = #{signRemark}</if>
111 111
             <if test="signScan != null  and signScan != ''"> and c.sign_scan = #{signScan}</if>
112 112
             <if test="commentType != null  and commentType != ''"> and c.comment_type = #{commentType}</if>
113
-            <if test="projectSource != null  and projectSource != ''"> and p.project_source = #{projectSource}</if>
114
-            <if test="projectName != null  and projectName != ''"> and p.project_name like concat('%', #{projectName}, '%')</if>
115
-            <if test="partyAName != null  and partyAName != ''"> and pa.party_a_name like concat('%', #{partyAName}, '%')</if>
116 113
         </where>
117 114
         group by c.contract_id
118 115
         order by c.draft_time desc
@@ -141,21 +138,21 @@
141 138
         left join cmc_project_contract as pc on pc.contract_id = t1.contract_id
142 139
         left join cmc_project as p on pc.project_id = p.project_id
143 140
         <where>
144
-            <if test="contractId != null  and contractId != ''"> and c.contract_id like concat('%', #{contractId}, '%')</if>
145
-            <if test="contractName!= null  and contractName != ''"> and c.contract_name like concat('%', #{contractName}, '%')</if>
146
-            <if test="contractCode!= null  and contractCode != ''"> and c.contract_code like concat('%', #{contractCode}, '%')</if>
147
-            <if test="tenderId != null  and tenderId != ''"> and c.tender_id = #{tenderId}</if>
148
-            <if test="contractNumber != null  and contractNumber != ''"> and c.contract_number = #{contractNumber}</if>
149
-            <if test="partyAId != null  and partyAId != ''"> and c.party_a_id = #{partyAId}</if>
150
-            <if test="amount != null "> and c.amount = #{amount}</if>
151
-            <if test="deposit != null "> and c.deposit = #{deposit}</if>
152
-            <if test="contractDocument != null  and contractDocument != ''"> and c.contract_document = #{contractDocument}</if>
153
-            <if test="drafter != null "> and c.drafter = #{drafter}</if>
154
-            <if test="draftTime != null "> and c.draft_time = #{draftTime}</if>
155
-            <if test="signDate != null "> and YEAR(c.sign_date) = YEAR(#{signDate})</if>
156
-            <if test="signRemark != null  and signRemark != ''"> and c.sign_remark = #{signRemark}</if>
157
-            <if test="signScan != null  and signScan != ''"> and c.sign_scan = #{signScan}</if>
158
-            <if test="commentType != null  and commentType != ''"> and c.comment_type = #{commentType}</if>
141
+            <if test="contractId != null  and contractId != ''"> and t1.contract_id like concat('%', #{contractId}, '%')</if>
142
+            <if test="contractName!= null  and contractName != ''"> and t1.contract_name like concat('%', #{contractName}, '%')</if>
143
+            <if test="contractCode!= null  and contractCode != ''"> and t1.contract_code like concat('%', #{contractCode}, '%')</if>
144
+            <if test="tenderId != null  and tenderId != ''"> and t1.tender_id = #{tenderId}</if>
145
+            <if test="contractNumber != null  and contractNumber != ''"> and t1.contract_number = #{contractNumber}</if>
146
+            <if test="partyAId != null  and partyAId != ''"> and t1.party_a_id = #{partyAId}</if>
147
+            <if test="amount != null "> and t1.amount = #{amount}</if>
148
+            <if test="deposit != null "> and t1.deposit = #{deposit}</if>
149
+            <if test="contractDocument != null  and contractDocument != ''"> and t1.contract_document = #{contractDocument}</if>
150
+            <if test="drafter != null "> and t1.drafter = #{drafter}</if>
151
+            <if test="draftTime != null "> and t1.draft_time = #{draftTime}</if>
152
+            <if test="signDate != null "> and YEAR(t1.sign_date) = YEAR(#{signDate})</if>
153
+            <if test="signRemark != null  and signRemark != ''"> and t1.sign_remark = #{signRemark}</if>
154
+            <if test="signScan != null  and signScan != ''"> and t1.sign_scan = #{signScan}</if>
155
+            <if test="commentType != null  and commentType != ''"> and t1.comment_type = #{commentType}</if>
159 156
             <if test="projectSource != null  and projectSource != ''"> and p.project_source = #{projectSource}</if>
160 157
             <if test="projectName != null  and projectName != ''"> and p.project_name like concat('%', #{projectName}, '%')</if>
161 158
             <if test="partyAName != null  and partyAName != ''"> and pa.party_a_name like concat('%', #{partyAName}, '%')</if>
@@ -192,58 +189,61 @@
192 189
             <if test="signRemark != null  and signRemark != ''"> and c.sign_remark = #{signRemark}</if>
193 190
             <if test="signScan != null  and signScan != ''"> and c.sign_scan = #{signScan}</if>
194 191
             <if test="commentType != null  and commentType != ''"> and c.comment_type = #{commentType}</if>
195
-            <if test="projectSource != null  and projectSource != ''"> and p.project_source = #{projectSource}</if>
196
-            <if test="projectName != null  and projectName != ''"> and p.project_name like concat('%', #{projectName}, '%')</if>
197
-            <if test="partyAName != null  and partyAName != ''"> and pa.party_a_name like concat('%', #{partyAName}, '%')</if>
198 192
         </where>
199 193
         group by c.contract_id
200 194
         order by c.draft_time desc
201 195
     </select>
202 196
 
203 197
     <select id="selectCmcContractListByRange" parameterType="CmcContract" resultMap="CmcContractResult">
204
-        select distinct c.contract_id, c.contract_code, c.contract_name, c.contract_number, c.tender_id, t.project_name as t_project_name, p.project_number, p.project_name,
205
-        p.project_source, c.party_a_id, pa.party_a_name, t.a_person as a_person, t.a_phone as a_phone, t.agent as agent, t.agent_person as agent_person,
198
+        select distinct t1.contract_id, t1.contract_code, t1.contract_name, t1.contract_number, t1.tender_id, t1.t_project_name,t1.party_a_id, t1.party_a_name, t1.a_person,
199
+        t1.a_phone, t1.agent, t1.agent_person,t1.paid_amount, t1.paid_percentage, t1.invoice_amount, t1.invoice_percentage, p.project_number, p.project_name, p.project_source,
200
+        t1.agent_phone, t1.amount, t1.deposit, t1.contract_document, t1.drafter, t1.draft_nick_name, t1.draft_time, t1.remark, t1.sign_date, t1.sign_remark, t1.sign_scan,
201
+        t1.comment_type, t1.manager_comment, t1.manager_user_id, t1.manager_nick_name, t1.manager_time, t1.gm_user_id, t1.gm_nick_name, t1.gm_time, t1.gm_comment from
202
+        (select distinct c.contract_id, c.contract_code, c.contract_name, c.contract_number, c.tender_id, t.project_name as t_project_name,c.party_a_id, pa.party_a_name,
203
+        t.a_person as a_person, t.a_phone as a_phone, t.agent as agent, t.agent_person as agent_person, t.agent_phone as agent_phone,
206 204
         sum(cp.paid_amount) as paid_amount, case c.amount when 0 then 0 else round(sum(cp.paid_amount) / c.amount * 100, 2) end as paid_percentage,
207 205
         sum(ci.invoice_amount) as invoice_amount, case c.amount when 0 then 0 else round(sum(ci.invoice_amount) / c.amount * 100, 2) end as invoice_percentage,
208
-        t.agent_phone as agent_phone, c.amount, c.deposit, c.contract_document, c.drafter, u.nick_name as draft_nick_name, c.draft_time, c.remark, c.sign_date, c.sign_remark, c.sign_scan,
206
+        c.amount, c.deposit, c.contract_document, c.drafter, u.nick_name as draft_nick_name, c.draft_time, c.remark, c.sign_date, c.sign_remark, c.sign_scan,
209 207
         c.comment_type, c.manager_comment, c.manager_user_id, u1.nick_name as manager_nick_name, c.manager_time, c.gm_user_id, u2.nick_name as gm_nick_name, c.gm_time, c.gm_comment from cmc_contract as c
210 208
         left join sys_user as u on u.user_id = c.drafter
211 209
         left join sys_user as u1 on u1.user_id = c.manager_user_id
212 210
         left join sys_user as u2 on u2.user_id = c.gm_user_id
213 211
         left join cmc_tender as t on t.tender_id = c.tender_id
214 212
         left join cmc_party_a as pa on pa.party_a_id = c.party_a_id
215
-        left join cmc_project_contract as pc on pc.contract_id = c.contract_id
216
-        left join cmc_project as p on pc.project_id = p.project_id
217 213
         left join cmc_contract_paid as cp on cp.contract_id = c.contract_id
218 214
         left join cmc_contract_invoice as ci on ci.contract_id = c.contract_id
215
+        group by c.contract_id)
216
+        as t1
217
+        left join cmc_project_contract as pc on pc.contract_id = t1.contract_id
218
+        left join cmc_project as p on pc.project_id = p.project_id
219 219
         <where>
220
-            <if test="contractId != null  and contractId != ''"> and c.contract_id like concat('%', #{contractId}, '%')</if>
221
-            <if test="contractName!= null  and contractName != ''"> and c.contract_name like concat('%', #{contractName}, '%')</if>
222
-            <if test="contractCode!= null  and contractCode != ''"> and c.contract_code like concat('%', #{contractCode}, '%')</if>
223
-            <if test="tenderId != null  and tenderId != ''"> and c.tender_id = #{tenderId}</if>
224
-            <if test="contractNumber != null  and contractNumber != ''"> and c.contract_number = #{contractNumber}</if>
225
-            <if test="partyAId != null  and partyAId != ''"> and c.party_a_id = #{partyAId}</if>
226
-            <if test="amount != null "> and c.amount = #{amount}</if>
227
-            <if test="deposit != null "> and c.deposit = #{deposit}</if>
228
-            <if test="contractDocument != null  and contractDocument != ''"> and c.contract_document = #{contractDocument}</if>
229
-            <if test="drafter != null "> and c.drafter = #{drafter}</if>
230
-            <if test="draftTime != null "> and c.draft_time = #{draftTime}</if>
231
-            <if test="signDate != null"> and YEAR(c.sign_date) = YEAR(#{signDate})</if>
232
-            <if test="signRemark != null  and signRemark != ''"> and c.sign_remark = #{signRemark}</if>
233
-            <if test="signScan != null  and signScan != ''"> and c.sign_scan = #{signScan}</if>
234
-            <if test="commentType != null  and commentType != ''"> and c.comment_type = #{commentType}</if>
220
+            <if test="contractId != null  and contractId != ''"> and t1.contract_id like concat('%', #{contractId}, '%')</if>
221
+            <if test="contractName!= null  and contractName != ''"> and t1.contract_name like concat('%', #{contractName}, '%')</if>
222
+            <if test="contractCode!= null  and contractCode != ''"> and t1.contract_code like concat('%', #{contractCode}, '%')</if>
223
+            <if test="tenderId != null  and tenderId != ''"> and t1.tender_id = #{tenderId}</if>
224
+            <if test="contractNumber != null  and contractNumber != ''"> and t1.contract_number = #{contractNumber}</if>
225
+            <if test="partyAId != null  and partyAId != ''"> and t1.party_a_id = #{partyAId}</if>
226
+            <if test="amount != null "> and t1.amount = #{amount}</if>
227
+            <if test="deposit != null "> and t1.deposit = #{deposit}</if>
228
+            <if test="contractDocument != null  and contractDocument != ''"> and t1.contract_document = #{contractDocument}</if>
229
+            <if test="drafter != null "> and t1.drafter = #{drafter}</if>
230
+            <if test="draftTime != null "> and t1.draft_time = #{draftTime}</if>
231
+            <if test="signDate != null"> and YEAR(t1.sign_date) = YEAR(#{signDate})</if>
232
+            <if test="signRemark != null  and signRemark != ''"> and t1.sign_remark = #{signRemark}</if>
233
+            <if test="signScan != null  and signScan != ''"> and t1.sign_scan = #{signScan}</if>
234
+            <if test="commentType != null  and commentType != ''"> and t1.comment_type = #{commentType}</if>
235 235
             <if test="projectSource != null  and projectSource != ''"> and p.project_source = #{projectSource}</if>
236 236
             <if test="projectName != null  and projectName != ''"> and p.project_name like concat('%', #{projectName}, '%')</if>
237 237
             <if test="partyAName != null  and partyAName != ''"> and pa.party_a_name like concat('%', #{partyAName}, '%')</if>
238 238
             <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
239
-                and date_format(c.sign_date,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
239
+                and date_format(t1.sign_date,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
240 240
             </if>
241 241
             <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
242
-                and date_format(c.sign_date,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
242
+                and date_format(t1.sign_date,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
243 243
             </if>
244 244
         </where>
245
-        group by c.contract_id
246
-        order by c.draft_time desc
245
+        group by t1.contract_id
246
+        order by t1.draft_time desc
247 247
     </select>
248 248
 
249 249
     <select id="selectCmcContractStatistic" resultMap="CmcContractResult" >

+ 73
- 21
oa-back/ruoyi-system/src/main/resources/mapper/oa/CmcSubContractMapper.xml Dosyayı Görüntüle

@@ -67,14 +67,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
67 67
         select distinct sc.sub_contract_id, sc.sub_contract_name, sc.sub_amount, sc.partner_id, pa.partner_name, sc.contact_person, sc.telephone, sc.contract_document, sc.drafter,
68 68
         sum(cp.paid_amount) as paid_amount, case sc.sub_amount when 0 then 0 else round(sum(cp.paid_amount) / sc.sub_amount * 100, 2) end as paid_percentage,
69 69
         sum(ci.invoice_amount) as invoice_amount, case sc.sub_amount when 0 then 0 else round(sum(ci.invoice_amount) / sc.sub_amount * 100, 2) end as invoice_percentage,
70
-        p.project_number, p.project_name, p.project_source,u.nick_name as draft_nick_name, sc.draft_time, sc.remark, sc.sign_date, sc.sign_remark, sc.sign_scan, sc.comment_type, sc.manager_comment,
70
+        u.nick_name as draft_nick_name, sc.draft_time, sc.remark, sc.sign_date, sc.sign_remark, sc.sign_scan, sc.comment_type, sc.manager_comment,
71 71
         sc.manager_user_id, u1.nick_name as manager_nick_name, sc.manager_time, sc.gm_user_id, u2.nick_name as gm_nick_name, sc.gm_time, sc.gm_comment from cmc_sub_contract as sc
72 72
         left join sys_user as u on u.user_id = sc.drafter
73 73
         left join sys_user as u1 on u1.user_id = sc.manager_user_id
74 74
         left join sys_user as u2 on u2.user_id = sc.gm_user_id
75 75
         left join cmc_partner as pa on pa.partner_id = sc.partner_id
76
-        left join cmc_project_sub_contract as psc on psc.sub_contract_id = sc.sub_contract_id
77
-        left join cmc_project as p on psc.project_id = p.project_id
78 76
         left join cmc_contract_paid as cp on cp.contract_id = sc.sub_contract_id
79 77
         left join cmc_contract_invoice as ci on ci.contract_id = sc.sub_contract_id
80 78
     </sql>
@@ -94,37 +92,91 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
94 92
             <if test="signRemark != null  and signRemark != ''"> and sc.sign_remark = #{signRemark}</if>
95 93
             <if test="signScan != null  and signScan != ''"> and sc.sign_scan = #{signScan}</if>
96 94
             <if test="commentType != null  and commentType != ''"> and sc.comment_type = #{commentType}</if>
97
-            <if test="projectSource != null  and projectSource != ''"> and p.project_source = #{projectSource}</if>
98 95
         </where>
99 96
         group by sc.sub_contract_id
100 97
         order by sc.draft_time desc
101 98
     </select>
102 99
 
100
+    <select id="selectCmcSubContractListP" parameterType="CmcSubContract" resultMap="CmcSubContractResult">
101
+        select distinct t1.sub_contract_id, t1.sub_contract_name, t1.sub_amount, t1.partner_id, t1.partner_name, t1.contact_person, t1.telephone, t1.contract_document, t1.drafter,
102
+        t1.paid_amount, t1.paid_percentage, t1.invoice_amount, t1.invoice_percentage, t1.draft_nick_name, t1.draft_time, t1.remark, t1.sign_date, t1.sign_remark, t1.sign_scan,
103
+        t1.comment_type, t1.manager_comment, t1.manager_user_id, t1.manager_nick_name, t1.manager_time, t1.gm_user_id, t1.gm_nick_name, t1.gm_time, t1.gm_comment, p.project_number, p.project_name, p.project_source from
104
+        (select distinct sc.sub_contract_id, sc.sub_contract_name, sc.sub_amount, sc.partner_id, pa.partner_name, sc.contact_person, sc.telephone, sc.contract_document, sc.drafter,
105
+        sum(cp.paid_amount) as paid_amount, case sc.sub_amount when 0 then 0 else round(sum(cp.paid_amount) / sc.sub_amount * 100, 2) end as paid_percentage,
106
+        sum(ci.invoice_amount) as invoice_amount, case sc.sub_amount when 0 then 0 else round(sum(ci.invoice_amount) / sc.sub_amount * 100, 2) end as invoice_percentage,
107
+        u.nick_name as draft_nick_name, sc.draft_time, sc.remark, sc.sign_date, sc.sign_remark, sc.sign_scan, sc.comment_type, sc.manager_comment,
108
+        sc.manager_user_id, u1.nick_name as manager_nick_name, sc.manager_time, sc.gm_user_id, u2.nick_name as gm_nick_name, sc.gm_time, sc.gm_comment from cmc_sub_contract as sc
109
+        left join sys_user as u on u.user_id = sc.drafter
110
+        left join sys_user as u1 on u1.user_id = sc.manager_user_id
111
+        left join sys_user as u2 on u2.user_id = sc.gm_user_id
112
+        left join cmc_partner as pa on pa.partner_id = sc.partner_id
113
+        left join cmc_contract_paid as cp on cp.contract_id = sc.sub_contract_id
114
+        left join cmc_contract_invoice as ci on ci.contract_id = sc.sub_contract_id
115
+        group by sc.sub_contract_id)
116
+        as t1
117
+        left join cmc_project_sub_contract as psc on psc.sub_contract_id = t1.sub_contract_id
118
+        left join cmc_project as p on psc.project_id = p.project_id
119
+        <where>
120
+            <if test="subContractName != null  and subContractName != ''"> and t1.sub_contract_name like concat('%', #{subContractName}, '%')</if>
121
+            <if test="subAmount != null "> and t1.sub_amount = #{subAmount}</if>
122
+            <if test="partnerId != null  and partnerId != ''"> and t1.partner_id = #{partnerId}</if>
123
+            <if test="contactPerson != null  and contactPerson != ''"> and t1.contact_person = #{contactPerson}</if>
124
+            <if test="telephone != null  and telephone != ''"> and t1.telephone = #{telephone}</if>
125
+            <if test="contractDocument != null  and contractDocument != ''"> and t1.contract_document = #{contractDocument}</if>
126
+            <if test="drafter != null "> and t1.drafter = #{drafter}</if>
127
+            <if test="draftTime != null "> and t1.draft_time = #{draftTime}</if>
128
+            <if test="signDate != null "> and YEAR(t1.sign_date) = YEAR(#{signDate})</if>
129
+            <if test="signRemark != null  and signRemark != ''"> and t1.sign_remark = #{signRemark}</if>
130
+            <if test="signScan != null  and signScan != ''"> and t1.sign_scan = #{signScan}</if>
131
+            <if test="commentType != null  and commentType != ''"> and t1.comment_type = #{commentType}</if>
132
+            <if test="projectSource != null  and projectSource != ''"> and p.project_source = #{projectSource}</if>
133
+        </where>
134
+        group by t1.sub_contract_id
135
+        order by t1.draft_time desc
136
+    </select>
137
+
103 138
     <select id="selectCmcSubContractListByRange" parameterType="CmcSubContract" resultMap="CmcSubContractResult">
104
-        <include refid="selectCmcSubContractVo"/>
139
+        select distinct t1.sub_contract_id, t1.sub_contract_name, t1.sub_amount, t1.partner_id, t1.partner_name, t1.contact_person, t1.telephone, t1.contract_document, t1.drafter,
140
+        t1.paid_amount, t1.paid_percentage, t1.invoice_amount, t1.invoice_percentage, t1.draft_nick_name, t1.draft_time, t1.remark, t1.sign_date, t1.sign_remark, t1.sign_scan,
141
+        t1.comment_type, t1.manager_comment, t1.manager_user_id, t1.manager_nick_name, t1.manager_time, t1.gm_user_id, t1.gm_nick_name, t1.gm_time, t1.gm_comment, p.project_number, p.project_name, p.project_source from
142
+        (select distinct sc.sub_contract_id, sc.sub_contract_name, sc.sub_amount, sc.partner_id, pa.partner_name, sc.contact_person, sc.telephone, sc.contract_document, sc.drafter,
143
+        sum(cp.paid_amount) as paid_amount, case sc.sub_amount when 0 then 0 else round(sum(cp.paid_amount) / sc.sub_amount * 100, 2) end as paid_percentage,
144
+        sum(ci.invoice_amount) as invoice_amount, case sc.sub_amount when 0 then 0 else round(sum(ci.invoice_amount) / sc.sub_amount * 100, 2) end as invoice_percentage,
145
+        u.nick_name as draft_nick_name, sc.draft_time, sc.remark, sc.sign_date, sc.sign_remark, sc.sign_scan, sc.comment_type, sc.manager_comment,
146
+        sc.manager_user_id, u1.nick_name as manager_nick_name, sc.manager_time, sc.gm_user_id, u2.nick_name as gm_nick_name, sc.gm_time, sc.gm_comment from cmc_sub_contract as sc
147
+        left join sys_user as u on u.user_id = sc.drafter
148
+        left join sys_user as u1 on u1.user_id = sc.manager_user_id
149
+        left join sys_user as u2 on u2.user_id = sc.gm_user_id
150
+        left join cmc_partner as pa on pa.partner_id = sc.partner_id
151
+        left join cmc_contract_paid as cp on cp.contract_id = sc.sub_contract_id
152
+        left join cmc_contract_invoice as ci on ci.contract_id = sc.sub_contract_id
153
+        group by sc.sub_contract_id)
154
+        as t1
155
+        left join cmc_project_sub_contract as psc on psc.sub_contract_id = t1.sub_contract_id
156
+        left join cmc_project as p on psc.project_id = p.project_id
105 157
         <where>
106
-            <if test="subContractName != null  and subContractName != ''"> and sc.sub_contract_name like concat('%', #{subContractName}, '%')</if>
107
-            <if test="subAmount != null "> and sc.sub_amount = #{subAmount}</if>
108
-            <if test="partnerId != null  and partnerId != ''"> and sc.partner_id = #{partnerId}</if>
109
-            <if test="contactPerson != null  and contactPerson != ''"> and sc.contact_person = #{contactPerson}</if>
110
-            <if test="telephone != null  and telephone != ''"> and sc.telephone = #{telephone}</if>
111
-            <if test="contractDocument != null  and contractDocument != ''"> and sc.contract_document = #{contractDocument}</if>
112
-            <if test="drafter != null "> and sc.drafter = #{drafter}</if>
113
-            <if test="draftTime != null "> and sc.draft_time = #{draftTime}</if>
114
-            <if test="signDate != null "> and YEAR(sc.sign_date) = YEAR(#{signDate})</if>
115
-            <if test="signRemark != null  and signRemark != ''"> and sc.sign_remark = #{signRemark}</if>
116
-            <if test="signScan != null  and signScan != ''"> and sc.sign_scan = #{signScan}</if>
117
-            <if test="commentType != null  and commentType != ''"> and sc.comment_type = #{commentType}</if>
158
+            <if test="subContractName != null  and subContractName != ''"> and t1.sub_contract_name like concat('%', #{subContractName}, '%')</if>
159
+            <if test="subAmount != null "> and t1.sub_amount = #{subAmount}</if>
160
+            <if test="partnerId != null  and partnerId != ''"> and t1.partner_id = #{partnerId}</if>
161
+            <if test="contactPerson != null  and contactPerson != ''"> and t1.contact_person = #{contactPerson}</if>
162
+            <if test="telephone != null  and telephone != ''"> and t1.telephone = #{telephone}</if>
163
+            <if test="contractDocument != null  and contractDocument != ''"> and t1.contract_document = #{contractDocument}</if>
164
+            <if test="drafter != null "> and t1.drafter = #{drafter}</if>
165
+            <if test="draftTime != null "> and t1.draft_time = #{draftTime}</if>
166
+            <if test="signDate != null "> and YEAR(t1.sign_date) = YEAR(#{signDate})</if>
167
+            <if test="signRemark != null  and signRemark != ''"> and t1.sign_remark = #{signRemark}</if>
168
+            <if test="signScan != null  and signScan != ''"> and t1.sign_scan = #{signScan}</if>
169
+            <if test="commentType != null  and commentType != ''"> and t1.comment_type = #{commentType}</if>
118 170
             <if test="projectSource != null  and projectSource != ''"> and p.project_source = #{projectSource}</if>
119 171
             <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
120
-                and date_format(sc.sign_date,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
172
+                and date_format(t1.sign_date,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
121 173
             </if>
122 174
             <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
123
-                and date_format(sc.sign_date,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
175
+                and date_format(t1.sign_date,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
124 176
             </if>
125 177
         </where>
126
-        group by sc.sub_contract_id
127
-        order by sc.draft_time desc
178
+        group by t1.sub_contract_id
179
+        order by t1.draft_time desc
128 180
     </select>
129 181
 
130 182
     <select id="selectCmcSubContractBySubContractId" parameterType="String" resultMap="CmcSubContractResult">

Loading…
İptal
Kaydet