Ver código fonte

山西熏蒸优化

lvzhikai 5 anos atrás
pai
commit
8fff62d882

+ 38 - 26
depot-intelligent/src/main/java/com/chinaitop/depot/intelligent/fumigation/mapper/TFumigationPlanMapper.xml

@@ -117,7 +117,7 @@
117
     </if>
117
     </if>
118
   </select>
118
   </select>
119
   <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
119
   <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
120
-    select 
120
+    select
121
     <include refid="Base_Column_List" />
121
     <include refid="Base_Column_List" />
122
     from t_fumigation_plan
122
     from t_fumigation_plan
123
     where id = #{id,jdbcType=VARCHAR}
123
     where id = #{id,jdbcType=VARCHAR}
@@ -133,29 +133,29 @@
133
     </if>
133
     </if>
134
   </delete>
134
   </delete>
135
   <insert id="insert" useGeneratedKeys="true" keyProperty="id" parameterType="com.chinaitop.depot.intelligent.fumigation.model.TFumigationPlan" >
135
   <insert id="insert" useGeneratedKeys="true" keyProperty="id" parameterType="com.chinaitop.depot.intelligent.fumigation.model.TFumigationPlan" >
136
-    insert into t_fumigation_plan (id, house_id, keeper, 
137
-      grain_kind, grain_count, grain_storage_time, 
138
-      fumigation_type, fumigation_number, fumigation_command, 
139
-      fumigation_operation, fumiagtion_protective, 
140
-      expected, points_work, note, 
141
-      state, creater, create_time, 
142
-      approve_people, approve_department, approve_note, 
143
-      approve_time, delete_state, org_id, 
144
-      fumigation_frequency, cgxzfs, hlxzfs, 
145
-      hlxzynhljsjh, xzfazd, xzfaqcr, 
146
-      xzfapzr, xzfabbqk, xzfzr, 
136
+    insert into t_fumigation_plan (id, house_id, keeper,
137
+      grain_kind, grain_count, grain_storage_time,
138
+      fumigation_type, fumigation_number, fumigation_command,
139
+      fumigation_operation, fumiagtion_protective,
140
+      expected, points_work, note,
141
+      state, creater, create_time,
142
+      approve_people, approve_department, approve_note,
143
+      approve_time, delete_state, org_id,
144
+      fumigation_frequency, cgxzfs, hlxzfs,
145
+      hlxzynhljsjh, xzfazd, xzfaqcr,
146
+      xzfapzr, xzfabbqk, xzfzr,
147
       hcjcdh, updatetime)
147
       hcjcdh, updatetime)
148
-    values (#{id,jdbcType=VARCHAR}, #{houseId,jdbcType=INTEGER}, #{keeper,jdbcType=INTEGER}, 
148
+    values (#{id,jdbcType=VARCHAR}, #{houseId,jdbcType=INTEGER}, #{keeper,jdbcType=INTEGER},
149
       #{grainKind,jdbcType=INTEGER}, #{grainCount,jdbcType=DECIMAL}, #{grainStorageTime,jdbcType=TIMESTAMP},
149
       #{grainKind,jdbcType=INTEGER}, #{grainCount,jdbcType=DECIMAL}, #{grainStorageTime,jdbcType=TIMESTAMP},
150
-      #{fumigationType,jdbcType=INTEGER}, #{fumigationNumber,jdbcType=INTEGER}, #{fumigationCommand,jdbcType=VARCHAR}, 
151
-      #{fumigationOperation,jdbcType=VARCHAR}, #{fumiagtionProtective,jdbcType=VARCHAR}, 
152
-      #{expected,jdbcType=VARCHAR}, #{pointsWork,jdbcType=VARCHAR}, #{note,jdbcType=VARCHAR}, 
153
-      #{state,jdbcType=INTEGER}, #{creater,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, 
154
-      #{approvePeople,jdbcType=VARCHAR}, #{approveDepartment,jdbcType=VARCHAR}, #{approveNote,jdbcType=VARCHAR}, 
155
-      #{approveTime,jdbcType=TIMESTAMP}, #{deleteState,jdbcType=VARCHAR}, #{orgId,jdbcType=VARCHAR}, 
156
-      #{fumigationFrequency,jdbcType=INTEGER}, #{cgxzfs,jdbcType=VARCHAR}, #{hlxzfs,jdbcType=VARCHAR}, 
157
-      #{hlxzynhljsjh,jdbcType=VARCHAR}, #{xzfazd,jdbcType=VARCHAR}, #{xzfaqcr,jdbcType=VARCHAR}, 
158
-      #{xzfapzr,jdbcType=VARCHAR}, #{xzfabbqk,jdbcType=VARCHAR}, #{xzfzr,jdbcType=VARCHAR}, 
150
+      #{fumigationType,jdbcType=INTEGER}, #{fumigationNumber,jdbcType=INTEGER}, #{fumigationCommand,jdbcType=VARCHAR},
151
+      #{fumigationOperation,jdbcType=VARCHAR}, #{fumiagtionProtective,jdbcType=VARCHAR},
152
+      #{expected,jdbcType=VARCHAR}, #{pointsWork,jdbcType=VARCHAR}, #{note,jdbcType=VARCHAR},
153
+      #{state,jdbcType=INTEGER}, #{creater,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
154
+      #{approvePeople,jdbcType=VARCHAR}, #{approveDepartment,jdbcType=VARCHAR}, #{approveNote,jdbcType=VARCHAR},
155
+      #{approveTime,jdbcType=TIMESTAMP}, #{deleteState,jdbcType=VARCHAR}, #{orgId,jdbcType=VARCHAR},
156
+      #{fumigationFrequency,jdbcType=INTEGER}, #{cgxzfs,jdbcType=VARCHAR}, #{hlxzfs,jdbcType=VARCHAR},
157
+      #{hlxzynhljsjh,jdbcType=VARCHAR}, #{xzfazd,jdbcType=VARCHAR}, #{xzfaqcr,jdbcType=VARCHAR},
158
+      #{xzfapzr,jdbcType=VARCHAR}, #{xzfabbqk,jdbcType=VARCHAR}, #{xzfzr,jdbcType=VARCHAR},
159
       #{hcjcdh,jdbcType=VARCHAR}, #{updatetime,jdbcType=TIMESTAMP})
159
       #{hcjcdh,jdbcType=VARCHAR}, #{updatetime,jdbcType=TIMESTAMP})
160
   </insert>
160
   </insert>
161
   <insert id="insertSelective" parameterType="com.chinaitop.depot.intelligent.fumigation.model.TFumigationPlan" >
161
   <insert id="insertSelective" parameterType="com.chinaitop.depot.intelligent.fumigation.model.TFumigationPlan" >
@@ -781,7 +781,19 @@
781
     approval.operator operator
781
     approval.operator operator
782
     FROM
782
     FROM
783
     t_fumigation_plan plan
783
     t_fumigation_plan plan
784
-    LEFT JOIN t_fumigation_pesticide pes ON pes.fumigation_id = plan.id
784
+    LEFT JOIN (
785
+    SELECT
786
+    pest.fumigation_id,
787
+    pest.drug_name
788
+    FROM
789
+    t_fumigation_pesticide pest
790
+    WHERE
791
+    pest.org_id = #{orgId,jdbcType=INTEGER}
792
+    GROUP BY
793
+    pest.fumigation_id
794
+    ORDER BY
795
+    pest.updatetime
796
+    ) pes ON pes.fumigation_id = plan.id
785
     LEFT JOIN business_approval approval ON plan.id = approval.task_id
797
     LEFT JOIN business_approval approval ON plan.id = approval.task_id
786
     WHERE plan.org_id = #{orgId,jdbcType=INTEGER}
798
     WHERE plan.org_id = #{orgId,jdbcType=INTEGER}
787
     AND plan.state != 1
799
     AND plan.state != 1
@@ -796,7 +808,7 @@
796
     select
808
     select
797
     plan.*
809
     plan.*
798
     FROM t_fumigation_plan plan
810
     FROM t_fumigation_plan plan
799
-    LEFT JOIN t_fumigation_process pro ON pro.fumigation_id = plan.id
811
+    LEFT JOIN t_fumigation_process pro ON pro.fumigation_id = plan.id AND pro.delete_state = 1
800
     WHERE 1=1
812
     WHERE 1=1
801
     <if test="houseId != null" >
813
     <if test="houseId != null" >
802
       AND plan.house_id = #{houseId,jdbcType=INTEGER}
814
       AND plan.house_id = #{houseId,jdbcType=INTEGER}
@@ -820,11 +832,11 @@
820
     basic_storehouse sh
832
     basic_storehouse sh
821
     INNER JOIN t_ccvalue tc ON tc.org_id = sh.org_id AND tc.v_cf_code = sh.storehouse_code
833
     INNER JOIN t_ccvalue tc ON tc.org_id = sh.org_id AND tc.v_cf_code = sh.storehouse_code
822
     where not exists (SELECT hcjcdh FROM t_fumigation_plan tp
834
     where not exists (SELECT hcjcdh FROM t_fumigation_plan tp
823
-    WHERE  tp.id != #{fumigationId,jdbcType=VARCHAR} AND tp.hcjcdh = tc.hcjcdh)
835
+    WHERE tp.delete_state = 1 AND tp.id != #{fumigationId,jdbcType=VARCHAR} AND tp.hcjcdh = tc.hcjcdh)
824
     <if test="houseId != null">
836
     <if test="houseId != null">
825
       AND sh.storehouse_id = #{houseId,jdbcType=INTEGER}
837
       AND sh.storehouse_id = #{houseId,jdbcType=INTEGER}
826
     </if>
838
     </if>
827
     AND tc.hcjcdh is not null
839
     AND tc.hcjcdh is not null
828
-    GROUP BY tc.hcjcdh
840
+    GROUP BY tc.hcjcdh ORDER BY tc.updatetime desc
829
   </select>
841
   </select>
830
 </mapper>
842
 </mapper>