fanxw 11 月之前
父节点
当前提交
8377c31ded

+ 48 - 11
src/main/java/com/chinaitop/depot/keeperAccount/controller/StorageFcbgzController.java

@@ -48,10 +48,11 @@ public class StorageFcbgzController {
48
     	@ApiImplicitParam(name="jznd", value="记账年度", paramType="query"),
48
     	@ApiImplicitParam(name="jznd", value="记账年度", paramType="query"),
49
     	@ApiImplicitParam(name="dataStatus", value="是否记账(0:已记账,1:未记账)", paramType="query"),
49
     	@ApiImplicitParam(name="dataStatus", value="是否记账(0:已记账,1:未记账)", paramType="query"),
50
     	@ApiImplicitParam(name="sfjz", value="是否结转(0:是,1:否)", paramType="query"),
50
     	@ApiImplicitParam(name="sfjz", value="是否结转(0:是,1:否)", paramType="query"),
51
-    	@ApiImplicitParam(name="orgId", value="库ID", paramType="query")
51
+    	@ApiImplicitParam(name="orgId", value="库ID", paramType="query"),
52
+    	@ApiImplicitParam(name="ylorcpl", value="原粮或者成品粮(0:原粮,1:成品粮)", paramType="query")
52
     })
53
     })
53
 	public PageInfo<StorageFcbgz> getListFcbgz(Integer pageNum, Integer pageSize, 
54
 	public PageInfo<StorageFcbgz> getListFcbgz(Integer pageNum, Integer pageSize, 
54
-			Integer lspz, Integer lsxz, String jznd, String dataStatus, String sfjz, Integer orgId) {
55
+			Integer lspz, Integer lsxz, String jznd, String dataStatus, String sfjz, Integer orgId, String ylorcpl) {
55
 
56
 
56
 		List<StorageFcbgz> list = null;
57
 		List<StorageFcbgz> list = null;
57
 
58
 
@@ -59,7 +60,7 @@ public class StorageFcbgzController {
59
 			if (pageNum!=null && pageSize!=null) {
60
 			if (pageNum!=null && pageSize!=null) {
60
 				PageHelper.startPage(pageNum, pageSize);
61
 				PageHelper.startPage(pageNum, pageSize);
61
 			}
62
 			}
62
-			list = storageFcbgzService.selectFcbgzList(lspz, lsxz, jznd, dataStatus, sfjz, orgId);
63
+			list = storageFcbgzService.selectFcbgzList(lspz, lsxz, jznd, dataStatus, sfjz, orgId, ylorcpl);
63
 		} catch (Exception e) {
64
 		} catch (Exception e) {
64
 			logger.error(e.getMessage(), e);
65
 			logger.error(e.getMessage(), e);
65
 		}
66
 		}
@@ -162,9 +163,11 @@ public class StorageFcbgzController {
162
 		}
163
 		}
163
 	}
164
 	}
164
 
165
 
165
-	@Scheduled(cron = "00 00 23 * * ?")
166
+	//@Scheduled(cron = "00 00 23 * * ?")//每天23点执行一次
167
+	//每个小时执行一次
168
+	@Scheduled(cron = "0 0 * * * ?")
166
 	@RequestMapping(value="/timedGenerationFcbgzSclData", method = RequestMethod.GET)
169
 	@RequestMapping(value="/timedGenerationFcbgzSclData", method = RequestMethod.GET)
167
-	@ApiOperation(value="定时生成省级储备粮分仓保管账数据", notes = "每天23点执行一次")
170
+	@ApiOperation(value="定时生成原粮省级储备粮分仓保管账数据", notes = "每个小时执行一次")
168
 	public void timedGenerationFcbgzSclData() {
171
 	public void timedGenerationFcbgzSclData() {
169
 		try {
172
 		try {
170
 			storageFcbgzService.timedGenerationFcbgzData(null, "6877", null, "0");
173
 			storageFcbgzService.timedGenerationFcbgzData(null, "6877", null, "0");
@@ -174,9 +177,11 @@ public class StorageFcbgzController {
174
 		System.out.println("结束了");
177
 		System.out.println("结束了");
175
 	}
178
 	}
176
 
179
 
177
-	@Scheduled(cron = "0 15 23 * * ?")
180
+	//@Scheduled(cron = "0 15 23 * * ?")//每天23点15执行一次
181
+	//每小时的第15分钟0秒触发一次任务‌。
182
+	@Scheduled(cron = "0 15 * * * ?")
178
 	@RequestMapping(value="/timedGenerationFcbgzSplData", method = RequestMethod.GET)
183
 	@RequestMapping(value="/timedGenerationFcbgzSplData", method = RequestMethod.GET)
179
-	@ApiOperation(value="定时生成商品粮分仓保管账数据", notes = "每天23点15执行一次")
184
+	@ApiOperation(value="定时生成原粮商品粮分仓保管账数据", notes = "每小时的第15分钟0秒触发一次")
180
 	public void timedGenerationFcbgzSplData() {
185
 	public void timedGenerationFcbgzSplData() {
181
 		try {
186
 		try {
182
 			storageFcbgzService.timedGenerationFcbgzData(null, "3052", null, "0");
187
 			storageFcbgzService.timedGenerationFcbgzData(null, "3052", null, "0");
@@ -186,8 +191,22 @@ public class StorageFcbgzController {
186
 		System.out.println("结束了");
191
 		System.out.println("结束了");
187
 	}
192
 	}
188
 
193
 
194
+	//@Scheduled(cron = "00 00 23 * * ?")//每天23点执行一次
195
+	//每个小时执行一次
196
+	@Scheduled(cron = "0 0 * * * ?")
197
+	@RequestMapping(value="/timedGenerationCplFcbgzData", method = RequestMethod.GET)
198
+	@ApiOperation(value="定时生成原粮省级储备粮分仓保管账数据", notes = "每个小时执行一次")
199
+	public void timedGenerationCplFcbgzSclData() {
200
+		try {
201
+			storageFcbgzService.timedGenerationCplFcbgzData(null, "6877", null, "1");
202
+		} catch (Exception e) {
203
+			logger.error(e.getMessage(), e);
204
+		}
205
+		System.out.println("结束了");
206
+	}
207
+
189
 	@RequestMapping(value="/timedGenerationFcbgzData_test", method = RequestMethod.GET)
208
 	@RequestMapping(value="/timedGenerationFcbgzData_test", method = RequestMethod.GET)
190
-	@ApiOperation(value="定时生成保管账数据_手动生成接口", notes = "")
209
+	@ApiOperation(value="定时生成原粮保管账数据_手动生成接口", notes = "")
191
 	@ApiImplicitParams({
210
 	@ApiImplicitParams({
192
     	@ApiImplicitParam(name="orgId", value="库ID", paramType="query"),
211
     	@ApiImplicitParam(name="orgId", value="库ID", paramType="query"),
193
     	@ApiImplicitParam(name="hwxz", value="粮食性质", paramType="query"),
212
     	@ApiImplicitParam(name="hwxz", value="粮食性质", paramType="query"),
@@ -202,6 +221,23 @@ public class StorageFcbgzController {
202
 		}
221
 		}
203
 		System.out.println("结束了");
222
 		System.out.println("结束了");
204
 	}
223
 	}
224
+	
225
+	@RequestMapping(value="/timedGenerationCplFcbgzData_test", method = RequestMethod.GET)
226
+	@ApiOperation(value="定时生成成品粮保管账数据_手动生成接口", notes = "")
227
+	@ApiImplicitParams({
228
+    	@ApiImplicitParam(name="orgId", value="库ID", paramType="query"),
229
+    	@ApiImplicitParam(name="hwxz", value="粮食性质", paramType="query"),
230
+    	@ApiImplicitParam(name="rqs", value="记账日期", paramType="query"),
231
+    	@ApiImplicitParam(name="ylorcpl", value="原粮或者成品粮(0:原粮,1:成品粮)", paramType="query")
232
+    })
233
+	public void timedGenerationCplFcbgzData_test(String orgId, String hwxz, String rqs, String ylorcpl) {
234
+		try {
235
+			storageFcbgzService.timedGenerationCplFcbgzData(orgId, hwxz, rqs, ylorcpl);
236
+		} catch (Exception e) {
237
+			logger.error(e.getMessage(), e);
238
+		}
239
+		System.out.println("结束了");
240
+	}
205
 
241
 
206
 	@RequestMapping(value="/createHwsnjzData", method = RequestMethod.GET)
242
 	@RequestMapping(value="/createHwsnjzData", method = RequestMethod.GET)
207
 	@ApiOperation(value="手动生成一个货位的上年结转数据数据", notes = "")
243
 	@ApiOperation(value="手动生成一个货位的上年结转数据数据", notes = "")
@@ -210,9 +246,10 @@ public class StorageFcbgzController {
210
 		@ApiImplicitParam(name="ch", value="仓房ID", paramType="query"),
246
 		@ApiImplicitParam(name="ch", value="仓房ID", paramType="query"),
211
     	@ApiImplicitParam(name="hwh", value="货位ID", paramType="query"),
247
     	@ApiImplicitParam(name="hwh", value="货位ID", paramType="query"),
212
     	@ApiImplicitParam(name="jznd", value="记账年度", paramType="query"),
248
     	@ApiImplicitParam(name="jznd", value="记账年度", paramType="query"),
213
-    	@ApiImplicitParam(name="lsxz", value="粮食性质", paramType="query")
249
+    	@ApiImplicitParam(name="lsxz", value="粮食性质", paramType="query"),
250
+    	@ApiImplicitParam(name="ylorcpl", value="原粮或者成品粮(0:原粮,1:成品粮)", paramType="query")
214
     })
251
     })
215
-	public void createHwsnjzData(String orgId, Integer ch, Integer hwh, String jznd, Integer lsxz) {
216
-		storageFcbgzService.createHwsnjzData(orgId, ch, hwh, jznd, lsxz);
252
+	public void createHwsnjzData(String orgId, Integer ch, Integer hwh, String jznd, Integer lsxz, String ylorcpl) {
253
+		storageFcbgzService.createHwsnjzData(orgId, ch, hwh, jznd, lsxz, ylorcpl);
217
 	}
254
 	}
218
 }
255
 }

+ 7 - 0
src/main/java/com/chinaitop/depot/keeperAccount/mapper/StorageFcbgzMapper.java

@@ -43,6 +43,13 @@ public interface StorageFcbgzMapper {
43
      * @return
43
      * @return
44
      */
44
      */
45
 	List<StorageFcbgz> queryCrkFcbgzGroupBySplData(Map<String, Object> map);
45
 	List<StorageFcbgz> queryCrkFcbgzGroupBySplData(Map<String, Object> map);
46
+	
47
+	/**
48
+     * 根据成品粮分仓保管账表数据分组统计查询成品粮的省储粮数据
49
+     * @param map
50
+     * @return
51
+     */
52
+	List<StorageFcbgz> queryCplFcbgzGroupByCblData(Map<String, Object> map);
46
 
53
 
47
 	/**
54
 	/**
48
 	 * 新版分仓保管账查询列表
55
 	 * 新版分仓保管账查询列表

+ 76 - 0
src/main/java/com/chinaitop/depot/keeperAccount/mapper/StorageFcbgzMapper.xml

@@ -685,6 +685,9 @@
685
 	        <if test="jznd != null">
685
 	        <if test="jznd != null">
686
 	        and jznd=#{jznd,jdbcType=VARCHAR}
686
 	        and jznd=#{jznd,jdbcType=VARCHAR}
687
 	        </if>
687
 	        </if>
688
+	        <if test="ylorcpl != null">
689
+	        and ylorcpl=#{ylorcpl,jdbcType=VARCHAR}
690
+	        </if>
688
 	    ) datas 
691
 	    ) datas 
689
 	    where datas.rank=1
692
 	    where datas.rank=1
690
 	) a
693
 	) a
@@ -708,6 +711,9 @@
708
         <if test="jznd != null">
711
         <if test="jznd != null">
709
         and jznd=#{jznd,jdbcType=VARCHAR}
712
         and jznd=#{jznd,jdbcType=VARCHAR}
710
         </if>
713
         </if>
714
+        <if test="ylorcpl != null">
715
+        and ylorcpl=#{ylorcpl,jdbcType=VARCHAR}
716
+        </if>
711
 	    group by org_id, ch, hwh, pz, mxpz, lyxz, jznd
717
 	    group by org_id, ch, hwh, pz, mxpz, lyxz, jznd
712
 	) b on b.hwh=a.hwh and b.mxpz=a.mxpz and b.lyxz=a.lyxz and b.jznd=a.jznd
718
 	) b on b.hwh=a.hwh and b.mxpz=a.mxpz and b.lyxz=a.lyxz and b.jznd=a.jznd
713
 	left join (
719
 	left join (
@@ -726,6 +732,9 @@
726
         <if test="lyxz != null">
732
         <if test="lyxz != null">
727
         and lyxz=#{lyxz,jdbcType=INTEGER}
733
         and lyxz=#{lyxz,jdbcType=INTEGER}
728
         </if>
734
         </if>
735
+        <if test="ylorcpl != null">
736
+        and ylorcpl=#{ylorcpl,jdbcType=VARCHAR}
737
+        </if>
729
 	) c on c.hwh=a.hwh and c.jznd=a.jznd
738
 	) c on c.hwh=a.hwh and c.jznd=a.jznd
730
 	where 1=1 
739
 	where 1=1 
731
 	<if test="sfjz==1">
740
 	<if test="sfjz==1">
@@ -845,4 +854,71 @@
845
 	where b.rqs=a.rqs and b.mxpz=a.mxpz and b.org_id=a.org_id and b.cazylx=a.cazylx and b.lchjbm=a.lchjbm
854
 	where b.rqs=a.rqs and b.mxpz=a.mxpz and b.org_id=a.org_id and b.cazylx=a.cazylx and b.lchjbm=a.lchjbm
846
 	order by b.rq
855
 	order by b.rq
847
   </select>
856
   </select>
857
+  
858
+  <!-- 根据成品粮分仓保管账表数据分组统计查询成品粮的省储粮数据 -->
859
+  <select id="queryCplFcbgzGroupByCblData" parameterType="java.util.Map" resultMap="BaseResultMap">
860
+    select 
861
+	    a.jzrq, 
862
+	    case 
863
+	      when a.zylx='0' then 'RK'||replace(a.jzrq, '-', '')||c.storehouse_code||case when c.datatype='0' then d.warehouse_code else '01' end ||'001'
864
+	      when a.zylx='1' then 'CK'||replace(a.jzrq, '-', '')||c.storehouse_code||case when c.datatype='0' then d.warehouse_code else '01' end ||'001'
865
+	      else 'null'
866
+	    end jzpz,
867
+	    case 
868
+	      when a.zylx='0' then '入库'
869
+	      when a.zylx='1' then '出库'
870
+	      else 'null'
871
+	    end jzzy,
872
+	    a.hwxz lyxz, 
873
+	    a.pz pz,
874
+	    a.mxpz mxpz,
875
+	    a.zcsl,
876
+	    a.srsl,
877
+	    b.kcsl kcsl,
878
+	    a.org_id, a.ch, a.hwh, substr(a.jzrq, 1, 4) jznd,
879
+	    '0' data_type,
880
+	    '1' data_status,
881
+	    '0' ywlx,
882
+	    b.rq last_business_date
883
+    from (
884
+	    select 
885
+	        org_id, house_id ch, warehouse_id hwh, lspz pz, lsmxpz mxpz, lsxz hwxz, rqs jzrq, zylx,
886
+	        sum(srsl) srsl, sum(zcsl) zcsl
887
+	    from depot_yw_cpl_fcbgz_view_model 
888
+	    where 1=1 
889
+	    <if test="orgId != null">
890
+	    and org_id=#{orgId, jdbcType=VARCHAR}
891
+	    </if>
892
+	    <if test="hwxz != null">
893
+	    and lsxz=#{hwxz, jdbcType=VARCHAR}
894
+	    </if>
895
+	    <if test="rqs != null">
896
+	    and rqs=#{rqs, jdbcType=VARCHAR}
897
+	    </if>
898
+	    group by org_id, house_id, warehouse_id, lspz, lsmxpz, lsxz, rqs, zylx
899
+	) a
900
+	inner join (
901
+	    select f.* from (
902
+	        select 
903
+	            id, org_id, house_id ch, warehouse_id hwh, lsxz, lspz, lsmxpz mxpz, rqs, zylx, kcsl, rq,
904
+	            Row_Number() OVER (partition by org_id,house_id,warehouse_id,lsxz,lspz,lsmxpz,rqs,zylx order by rq desc) rank 
905
+	        from depot_yw_cpl_fcbgz_view_model 
906
+	        where 1=1 
907
+	        <if test="orgId != null">
908
+		    and org_id=#{orgId, jdbcType=VARCHAR}
909
+		    </if>
910
+		    <if test="hwxz != null">
911
+		    and lsxz=#{hwxz, jdbcType=VARCHAR}
912
+		    </if>
913
+		    <if test="rqs != null">
914
+		    and rqs=#{rqs, jdbcType=VARCHAR}
915
+		    </if>
916
+	    ) as f 
917
+	    where 1=1 and f.rank=1
918
+	) b on b.hwh=a.hwh
919
+	left join basic_storehouse c on c.storehouse_id=a.ch
920
+	left join basic_warehouse d on d.warehouse_id=a.hwh
921
+	where b.rqs=a.jzrq and b.mxpz=a.mxpz and b.org_id=a.org_id and b.zylx=a.zylx
922
+	order by b.rq
923
+  </select>
848
 </mapper>
924
 </mapper>

+ 16 - 3
src/main/java/com/chinaitop/depot/keeperAccount/service/StorageFcbgzService.java

@@ -14,12 +14,22 @@ public interface StorageFcbgzService {
14
 	 * @param orgId 粮库ID
14
 	 * @param orgId 粮库ID
15
 	 * @param hwxz 粮食性质
15
 	 * @param hwxz 粮食性质
16
 	 * @param rqs 执行日期
16
 	 * @param rqs 执行日期
17
-	 * @param ylorcpl 
17
+	 * @param ylorcpl 原粮或成品粮(0:原粮,1:成品粮)
18
 	 * @throws Exception
18
 	 * @throws Exception
19
 	 */
19
 	 */
20
 	void timedGenerationFcbgzData(String orgId, String hwxz, String rqs, String ylorcpl) throws Exception;
20
 	void timedGenerationFcbgzData(String orgId, String hwxz, String rqs, String ylorcpl) throws Exception;
21
 
21
 
22
 	/**
22
 	/**
23
+	 * 定时生成成品粮分仓保管账数据
24
+	 * @param orgId 粮库ID
25
+	 * @param hwxz 粮食性质
26
+	 * @param rqs 执行日期
27
+	 * @param ylorcpl 原粮或成品粮(0:原粮,1:成品粮)
28
+	 * @throws Exception
29
+	 */
30
+	void timedGenerationCplFcbgzData(String orgId, String hwxz, String rqs, String ylorcpl) throws Exception;
31
+
32
+	/**
23
 	 * 分仓保管账查询列表
33
 	 * 分仓保管账查询列表
24
 	 * @param lspz 品种
34
 	 * @param lspz 品种
25
 	 * @param lsxz 性质
35
 	 * @param lsxz 性质
@@ -27,9 +37,10 @@ public interface StorageFcbgzService {
27
 	 * @param dataStatus 是否记账(0:已记账,1:未记账)
37
 	 * @param dataStatus 是否记账(0:已记账,1:未记账)
28
 	 * @param sfjz 是否结转(0:是,1:否)
38
 	 * @param sfjz 是否结转(0:是,1:否)
29
 	 * @param orgId 库ID
39
 	 * @param orgId 库ID
40
+	 * @param ylorcpl 原粮或成品粮(0:原粮,1:成品粮)
30
 	 * @return
41
 	 * @return
31
 	 */
42
 	 */
32
-	List<StorageFcbgz> selectFcbgzList(Integer lspz, Integer lsxz, String jznd, String dataStatus, String sfjz, Integer orgId) throws Exception;
43
+	List<StorageFcbgz> selectFcbgzList(Integer lspz, Integer lsxz, String jznd, String dataStatus, String sfjz, Integer orgId, String ylorcpl) throws Exception;
33
 
44
 
34
 	/**
45
 	/**
35
 	 * 点记账
46
 	 * 点记账
@@ -97,6 +108,8 @@ public interface StorageFcbgzService {
97
 	 * @param hwh
108
 	 * @param hwh
98
 	 * @param jznd
109
 	 * @param jznd
99
 	 * @param lsxz
110
 	 * @param lsxz
111
+	 * @param ylorcpl 原粮或者成品粮(0:原粮,1:成品粮)
100
 	 */
112
 	 */
101
-	void createHwsnjzData(String orgId, Integer ch, Integer hwh, String jznd, Integer lsxz);
113
+	void createHwsnjzData(String orgId, Integer ch, Integer hwh, String jznd, Integer lsxz, String ylorcpl);
114
+
102
 }
115
 }

+ 75 - 11
src/main/java/com/chinaitop/depot/keeperAccount/service/impl/FcbgzUtilsServiceImpl.java

@@ -57,6 +57,7 @@ public class FcbgzUtilsServiceImpl {
57
 	public void saveOrUpdateHjz(StorageFcbgz f, String dataType)  throws Exception {
57
 	public void saveOrUpdateHjz(StorageFcbgz f, String dataType)  throws Exception {
58
 		StorageFcbgzExample example = new StorageFcbgzExample();
58
 		StorageFcbgzExample example = new StorageFcbgzExample();
59
 		StorageFcbgzExample.Criteria criteria = example.createCriteria();
59
 		StorageFcbgzExample.Criteria criteria = example.createCriteria();
60
+		criteria.andChEqualTo(f.getCh());//仓房号
60
 		criteria.andHwhEqualTo(f.getHwh());//货位
61
 		criteria.andHwhEqualTo(f.getHwh());//货位
61
 		criteria.andDataTypeEqualTo(dataType);//数据类型
62
 		criteria.andDataTypeEqualTo(dataType);//数据类型
62
 		criteria.andLyxzEqualTo(f.getLyxz());//粮食性质
63
 		criteria.andLyxzEqualTo(f.getLyxz());//粮食性质
@@ -71,22 +72,34 @@ public class FcbgzUtilsServiceImpl {
71
 		StorageFcbgz sf = null;
72
 		StorageFcbgz sf = null;
72
 		if (null != list && list.size() > 0) {
73
 		if (null != list && list.size() > 0) {
73
 			sf = list.get(0);
74
 			sf = list.get(0);
75
+			
76
+			List<StorageFcbgz> this_list = null;
77
+			if (StorageFcbgzUtils.DATA_TYPE_1.equals(dataType)) {
78
+				//查询这个月这个仓房货位这个性质的所有普通账数据
79
+				this_list = getOldStorageFcbgzList(null, null, f.getCh(), f.getHwh(), f.getMxpz(), f.getLyxz(), f.getJznd(), ParameterUtil.date2string1(f.getJzrq()).substring(0, 7), StorageFcbgzUtils.DATA_TYPE_0);
80
+			}
81
+			if (StorageFcbgzUtils.DATA_TYPE_2.equals(dataType)) {
82
+				//查询这个仓房货位这个性质的所有月合计账数据
83
+				this_list = getOldStorageFcbgzList(null, null, f.getCh(), f.getHwh(), null, f.getLyxz(), f.getJznd(), null, StorageFcbgzUtils.DATA_TYPE_1);
84
+			}
74
 
85
 
75
 			//收入数量
86
 			//收入数量
76
-			BigDecimal srsl = f.getSrsl().add(sf.getSrsl()).setScale(3, BigDecimal.ROUND_DOWN);
87
+			BigDecimal srsl = this_list.stream().map(StorageFcbgz::getSrsl).reduce(BigDecimal.ZERO, BigDecimal::add);
77
 			sf.setSrsl(srsl);
88
 			sf.setSrsl(srsl);
78
 
89
 
79
 			//支出数量
90
 			//支出数量
80
-			BigDecimal zcsl = f.getZcsl().add(sf.getZcsl()).setScale(3, BigDecimal.ROUND_DOWN);
91
+			BigDecimal zcsl = this_list.stream().map(StorageFcbgz::getZcsl).reduce(BigDecimal.ZERO, BigDecimal::add);
81
 			sf.setZcsl(zcsl);
92
 			sf.setZcsl(zcsl);
82
 
93
 
83
-			//损耗数量
84
-			BigDecimal shsl = f.getShsl().add(sf.getShsl()).setScale(3, BigDecimal.ROUND_DOWN);
85
-			sf.setShsl(shsl);
86
-
87
-			//溢余数量
88
-			BigDecimal yysl = f.getYysl().add(sf.getYysl()).setScale(3, BigDecimal.ROUND_DOWN);
89
-			sf.setYysl(yysl);
94
+			if ("0".equals(f.getYlorcpl())) {
95
+				//损耗数量
96
+				BigDecimal shsl = this_list.stream().map(StorageFcbgz::getShsl).reduce(BigDecimal.ZERO, BigDecimal::add);
97
+				sf.setShsl(shsl);
98
+				
99
+				//溢余数量
100
+				BigDecimal yysl = this_list.stream().map(StorageFcbgz::getYysl).reduce(BigDecimal.ZERO, BigDecimal::add);
101
+				sf.setYysl(yysl);
102
+			}
90
 
103
 
91
 			//库存数量
104
 			//库存数量
92
 			sf.setKcsl(f.getKcsl());
105
 			sf.setKcsl(f.getKcsl());
@@ -111,12 +124,63 @@ public class FcbgzUtilsServiceImpl {
111
 	}
124
 	}
112
 
125
 
113
 	/**
126
 	/**
114
-	 * 查询集合
115
-	 * @param order 排序方式
127
+	 * 查询已经生成的分仓保管账数据
128
+	 * @param jzpz
129
+	 * @param jzzy
130
+	 * @param ch
116
 	 * @param hwh
131
 	 * @param hwh
117
 	 * @param lspz
132
 	 * @param lspz
118
 	 * @param lsxz
133
 	 * @param lsxz
119
 	 * @param jznd
134
 	 * @param jznd
135
+	 * @param sjfm
136
+	 * @param dataType
137
+	 * @return
138
+	 * @throws Exception
139
+	 */
140
+	public List<StorageFcbgz> getOldStorageFcbgzList(String jzpz, String jzzy, Integer ch, Integer hwh, Integer lspz, Integer lsxz, String jznd, String sjfm, String dataType) throws Exception {
141
+		StorageFcbgzExample example = new StorageFcbgzExample();
142
+		StorageFcbgzExample.Criteria criteria = example.createCriteria();
143
+		if (StringUtils.isNotBlank(jzpz)) {
144
+			criteria.andJzpzEqualTo(jzpz);
145
+		}
146
+		if (StringUtils.isNotBlank(jzzy)) {
147
+			criteria.andJzzyEqualTo(jzzy);
148
+		}
149
+		if (null != ch) {
150
+			criteria.andChEqualTo(ch);
151
+		}
152
+		if (null != hwh) {
153
+			criteria.andHwhEqualTo(hwh);
154
+		}
155
+		if (null != lspz) {
156
+			criteria.andMxpzEqualTo(lspz);
157
+		}
158
+		if (null != lsxz) {
159
+			criteria.andLyxzEqualTo(lsxz);
160
+		}
161
+		if (StringUtils.isNotBlank(jznd)) {
162
+			criteria.andJzndEqualTo(jznd);
163
+		}
164
+		if (StringUtils.isNotBlank(sjfm)) {
165
+			criteria.andSjfmEqualTo(sjfm);
166
+		}
167
+		if (StringUtils.isNotBlank(dataType)) {
168
+			criteria.andDataTypeEqualTo(dataType);
169
+		}
170
+		example.setOrderByClause("cjsj desc");
171
+		List<StorageFcbgz> list = storageFcbgzMapper.selectByExample(example);
172
+
173
+		return list;
174
+	}
175
+
176
+	/**
177
+	 * 查询集合
178
+	 * @param order 排序方式
179
+	 * @param ch 仓房
180
+	 * @param hwh 货位
181
+	 * @param lspz 明细品种
182
+	 * @param lsxz 粮食性质
183
+	 * @param jznd 记账年度
120
 	 * @param sjfm 数据说明
184
 	 * @param sjfm 数据说明
121
 	 * @param dataType
185
 	 * @param dataType
122
 	 * @return
186
 	 * @return

+ 106 - 17
src/main/java/com/chinaitop/depot/keeperAccount/service/impl/StorageFcbgzServiceImpl.java

@@ -77,23 +77,35 @@ public class StorageFcbgzServiceImpl implements StorageFcbgzService {
77
 			for (int i = 0; i < list.size(); i++) {
77
 			for (int i = 0; i < list.size(); i++) {
78
 				f = list.get(i);
78
 				f = list.get(i);
79
 
79
 
80
-				//先查询这个货位在上一年有没有结转,不结转的话生成的数据不能展示出来
81
-				boolean flag = fcbgzUtilsServiceImpl.topYearJzData(f.getCh(), f.getHwh(), Integer.parseInt(f.getJznd())-1, f.getLyxz(), ylorcpl);
82
-
83
-				f.setId(UUID.randomUUID().toString().replace("-", ""));
84
-				f.setCjsj(new Date());
85
-				f.setSjfm(ParameterUtil.date2string1(f.getJzrq()).substring(0, 7));
86
-				f.setYlorcpl(ylorcpl);
87
-				if (StringUtils.isNotBlank(f.getJzzy())) {
88
-					f.setJzzy(f.getJzzy().replace(" ", ""));
89
-				}
80
+				//先查询这个货位在上一年有没有结转数据,没有就新增一条
81
+				Integer snnf = Integer.parseInt(f.getJznd())-1;
82
+				boolean flag = fcbgzUtilsServiceImpl.topYearJzData(f.getCh(), f.getHwh(), snnf, f.getLyxz(), ylorcpl);
90
 				if (flag) {
83
 				if (flag) {
91
-					f.setIsShow("0");
92
-				} else {
93
-					f.setIsShow("1");
84
+					createHwsnjzData(f.getOrgId(), f.getCh(), f.getHwh(), snnf.toString(), f.getLyxz(), ylorcpl);
94
 				}
85
 				}
95
 
86
 
96
-				storageFcbgzMapper.insert(f);
87
+				//看这条数据生成了没有,没有就新增,否则执行修改
88
+				List<StorageFcbgz> old_storageFcbgz_list = fcbgzUtilsServiceImpl.getOldStorageFcbgzList(f.getJzpz(), f.getJzzy(), f.getCh(), f.getHwh(), f.getMxpz(), f.getLyxz(), f.getJznd(), ParameterUtil.date2string1(f.getJzrq()).substring(0, 7), StorageFcbgzUtils.DATA_TYPE_0);
89
+				if (null == old_storageFcbgz_list || old_storageFcbgz_list.size() == 0) {//新增
90
+					f.setId(UUID.randomUUID().toString().replace("-", ""));
91
+					f.setCjsj(new Date());
92
+					f.setSjfm(ParameterUtil.date2string1(f.getJzrq()).substring(0, 7));
93
+					f.setYlorcpl(ylorcpl);
94
+					if (StringUtils.isNotBlank(f.getJzzy())) {
95
+						f.setJzzy(f.getJzzy().replace(" ", ""));
96
+					}
97
+					f.setIsShow("0");
98
+					storageFcbgzMapper.insert(f);
99
+				} else {//修改
100
+					StorageFcbgz old_storageFcbgz = old_storageFcbgz_list.get(0);
101
+					old_storageFcbgz.setSrsl(f.getSrsl());
102
+					old_storageFcbgz.setZcsl(f.getZcsl());
103
+					old_storageFcbgz.setKcsl(f.getKcsl());
104
+					old_storageFcbgz.setShsl(f.getShsl());
105
+					old_storageFcbgz.setYysl(f.getYysl());
106
+					storageFcbgzMapper.updateByPrimaryKey(old_storageFcbgz);
107
+					f = old_storageFcbgz;
108
+				}
97
 
109
 
98
 				//生成或修改月合计数据
110
 				//生成或修改月合计数据
99
 				fcbgzUtilsServiceImpl.saveOrUpdateHjz(f, StorageFcbgzUtils.DATA_TYPE_1);
111
 				fcbgzUtilsServiceImpl.saveOrUpdateHjz(f, StorageFcbgzUtils.DATA_TYPE_1);
@@ -106,7 +118,7 @@ public class StorageFcbgzServiceImpl implements StorageFcbgzService {
106
 
118
 
107
 	@Override
119
 	@Override
108
 	public List<StorageFcbgz> selectFcbgzList(Integer lspz, Integer lsxz, String jznd, String dataStatus,
120
 	public List<StorageFcbgz> selectFcbgzList(Integer lspz, Integer lsxz, String jznd, String dataStatus,
109
-			String sfjz, Integer orgId) {
121
+			String sfjz, Integer orgId, String ylorcpl) {
110
 		
122
 		
111
 		Map<String, Object> map = new HashMap<>();
123
 		Map<String, Object> map = new HashMap<>();
112
 		if (lspz != null) {
124
 		if (lspz != null) {
@@ -130,6 +142,9 @@ public class StorageFcbgzServiceImpl implements StorageFcbgzService {
130
 		if (null != orgId) {
142
 		if (null != orgId) {
131
 			map.put("orgId", orgId);
143
 			map.put("orgId", orgId);
132
 		}
144
 		}
145
+		if (StringUtils.isNotBlank(ylorcpl)) {
146
+			map.put("ylorcpl", ylorcpl);
147
+		}
133
 		List<StorageFcbgz> list = storageFcbgzMapper.selectFcbgzList(map);
148
 		List<StorageFcbgz> list = storageFcbgzMapper.selectFcbgzList(map);
134
 		return list;
149
 		return list;
135
 	}
150
 	}
@@ -178,7 +193,7 @@ public class StorageFcbgzServiceImpl implements StorageFcbgzService {
178
 					list.add(f_day);
193
 					list.add(f_day);
179
 				}
194
 				}
180
 				//查询这个月的合计数据
195
 				//查询这个月的合计数据
181
-				jznd_month_jz_sum_list = fcbgzUtilsServiceImpl.getList(null, ch, hwh, null, lsxz, jznd, null, StorageFcbgzUtils.DATA_TYPE_1);
196
+				jznd_month_jz_sum_list = fcbgzUtilsServiceImpl.getList(null, ch, hwh, null, lsxz, jznd, jzrq, StorageFcbgzUtils.DATA_TYPE_1);
182
 				if (null != jznd_month_jz_sum_list && jznd_month_jz_sum_list.size() > 0) {
197
 				if (null != jznd_month_jz_sum_list && jznd_month_jz_sum_list.size() > 0) {
183
 					list.add(jznd_month_jz_sum_list.get(0));
198
 					list.add(jznd_month_jz_sum_list.get(0));
184
 				}
199
 				}
@@ -613,7 +628,7 @@ public class StorageFcbgzServiceImpl implements StorageFcbgzService {
613
 	}
628
 	}
614
 
629
 
615
 	@Override
630
 	@Override
616
-	public void createHwsnjzData(String orgId, Integer ch, Integer hwh, String jznd, Integer lsxz) {
631
+	public void createHwsnjzData(String orgId, Integer ch, Integer hwh, String jznd, Integer lsxz, String ylorcpl) {
617
 		StorageFcbgz f = new StorageFcbgz();
632
 		StorageFcbgz f = new StorageFcbgz();
618
 		f.setId(UUID.randomUUID().toString().replace("-", ""));
633
 		f.setId(UUID.randomUUID().toString().replace("-", ""));
619
 		f.setOrgId(orgId);
634
 		f.setOrgId(orgId);
@@ -626,6 +641,7 @@ public class StorageFcbgzServiceImpl implements StorageFcbgzService {
626
 		f.setKcsl(new BigDecimal(0));
641
 		f.setKcsl(new BigDecimal(0));
627
 		f.setDataType("2");
642
 		f.setDataType("2");
628
 		f.setDataStatus("0");
643
 		f.setDataStatus("0");
644
+		f.setYlorcpl(ylorcpl);
629
 		if (lsxz == 3052) {
645
 		if (lsxz == 3052) {
630
 			f.setYwlx("2");
646
 			f.setYwlx("2");
631
 		} else {
647
 		} else {
@@ -637,4 +653,77 @@ public class StorageFcbgzServiceImpl implements StorageFcbgzService {
637
 		storageFcbgzMapper.insert(f);
653
 		storageFcbgzMapper.insert(f);
638
 	}
654
 	}
639
 
655
 
656
+	@Override
657
+	public void timedGenerationCplFcbgzData(String orgId, String hwxz, String rqs, String ylorcpl) throws Exception {
658
+		Map<String, Object> map = new HashMap<>();
659
+		if (StringUtils.isNotBlank(orgId)) {
660
+			map.put("orgId", orgId);
661
+		}
662
+		if (StringUtils.isNotBlank(hwxz)) {
663
+			map.put("hwxz", hwxz);
664
+		} else {
665
+			throw new Exception("粮食性质不能为空");
666
+		}
667
+		if (StringUtils.isNotBlank(rqs)) {
668
+			map.put("rqs", rqs);
669
+		} else {
670
+			map.put("rqs", ParameterUtil.getSysDate());
671
+		}
672
+
673
+		List<StorageFcbgz> list = null;
674
+		if (StorageFcbgzUtils.LSXZ_SJCBL.equals(hwxz)) {
675
+			list = storageFcbgzMapper.queryCplFcbgzGroupByCblData(map);
676
+		}
677
+
678
+		if (null != list && list.size() > 0) {
679
+			StorageFcbgz f = null;
680
+			for (int i = 0; i < list.size(); i++) {
681
+				f = list.get(i);
682
+
683
+				//先查询这个货位在上一年有没有结转数据,没有就新增一条
684
+				Integer snnf = Integer.parseInt(f.getJznd())-1;
685
+				boolean flag = fcbgzUtilsServiceImpl.topYearJzData(f.getCh(), f.getHwh(), snnf, f.getLyxz(), ylorcpl);
686
+				if (!flag) {
687
+					createHwsnjzData(f.getOrgId(), f.getCh(), f.getHwh(), snnf.toString(), f.getLyxz(), ylorcpl);
688
+				}
689
+
690
+				//看这条数据生成了没有,没有就新增,否则执行修改
691
+				List<StorageFcbgz> old_storageFcbgz_list = fcbgzUtilsServiceImpl.getOldStorageFcbgzList(f.getJzpz(), f.getJzzy(), f.getCh(), f.getHwh(), f.getMxpz(), f.getLyxz(), f.getJznd(), ParameterUtil.date2string1(f.getJzrq()).substring(0, 7), StorageFcbgzUtils.DATA_TYPE_0);
692
+				if (null == old_storageFcbgz_list || old_storageFcbgz_list.size() == 0) {//新增
693
+					f.setId(UUID.randomUUID().toString().replace("-", ""));
694
+					f.setCjsj(new Date());
695
+					f.setSjfm(ParameterUtil.date2string1(f.getJzrq()).substring(0, 7));
696
+					f.setYlorcpl(ylorcpl);
697
+					if (StringUtils.isNotBlank(f.getJzzy())) {
698
+						f.setJzzy(f.getJzzy().replace(" ", ""));
699
+					}
700
+					f.setIsShow("0");
701
+					f.setShsl(new BigDecimal(0));
702
+					f.setYysl(new BigDecimal(0));
703
+					storageFcbgzMapper.insert(f);
704
+				} else {//修改
705
+					StorageFcbgz old_storageFcbgz = old_storageFcbgz_list.get(0);
706
+					old_storageFcbgz.setSrsl(f.getSrsl());
707
+					old_storageFcbgz.setZcsl(f.getZcsl());
708
+					old_storageFcbgz.setKcsl(f.getKcsl());
709
+					if ("0".equals(f.getYlorcpl())) {
710
+						old_storageFcbgz.setShsl(f.getShsl());
711
+						old_storageFcbgz.setYysl(f.getYysl());
712
+					} else {
713
+						old_storageFcbgz.setShsl(new BigDecimal(0));
714
+						old_storageFcbgz.setYysl(new BigDecimal(0));
715
+					}
716
+					storageFcbgzMapper.updateByPrimaryKey(old_storageFcbgz);
717
+					f = old_storageFcbgz;
718
+				}
719
+
720
+				//生成或修改月合计数据
721
+				fcbgzUtilsServiceImpl.saveOrUpdateHjz(f, StorageFcbgzUtils.DATA_TYPE_1);
722
+
723
+				//生成或修改年结转数据
724
+				fcbgzUtilsServiceImpl.saveOrUpdateHjz(f, StorageFcbgzUtils.DATA_TYPE_2);
725
+			}
726
+		}
727
+	}
728
+
640
 }
729
 }