|
|
@@ -660,23 +660,52 @@ public class OmsTransOrderController extends BaseRESTfulController {
|
|
|
return success(pageList);
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "重传火运实绩->环保")
|
|
|
+ @ApiOperation(value = "重传火运实绩->环保", notes = "startDate/endDate 传 yyyy-MM-dd;busiType 传 0 采购、1 销售,不传默认 0")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "startDate", value = "开始日期 yyyy-MM-dd", dataType = "String", paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "endDate", value = "结束日期 yyyy-MM-dd", dataType = "String", paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "busiType", value = "传输类型 0采购 1销售", dataType = "String", paramType = "query")
|
|
|
+ })
|
|
|
@PostMapping("/trainResultResend")
|
|
|
- public RESTfulResult trainResultResend() throws Exception{
|
|
|
- List<Map<String, Object>> listXt = omsTransOrderMapper.getTrainResultForSend(null);
|
|
|
- //List<Map<String, Object>> listHa = omsTransOrderMapper.getTrainResultForSend("宏安");
|
|
|
+ public RESTfulResult trainResultResend(String startDate, String endDate, String busiType) throws Exception{
|
|
|
+ //传输类型:1 销售、0 采购(不传默认 0 采购火运)
|
|
|
+ if (busiType == null || busiType.trim().length() == 0) {
|
|
|
+ busiType = "0";
|
|
|
+ }
|
|
|
+ busiType = busiType.trim();
|
|
|
+ if (!"0".equals(busiType) && !"1".equals(busiType)) {
|
|
|
+ String msg = "传输类型 busiType 只能传 0(采购)或 1(销售)!";
|
|
|
+ return failed(msg, msg);
|
|
|
+ }
|
|
|
+ List<Map<String, Object>> listXt = omsTransOrderMapper.getTrainResultForSend(null, startDate, endDate, busiType);
|
|
|
+ if (listXt == null || listXt.size() < 1) {
|
|
|
+ return success("没有需要重传的数据(传输类型:" + ("0".equals(busiType) ? "采购" : "销售")
|
|
|
+ + ",时间范围:" + (startDate == null ? "不限" : startDate) + " ~ " + (endDate == null ? "不限" : endDate) + ")");
|
|
|
+ }
|
|
|
int index= 0,section = 300;//分片大小
|
|
|
- while(index * section < listXt.size()) {
|
|
|
+ int total = listXt.size();
|
|
|
+ int successCount = 0;
|
|
|
+ log.info("重传火运实绩->环保:busiType=" + busiType + ",时间范围 " + startDate + " ~ " + endDate + ",共 " + total + " 条");
|
|
|
+ while(index * section < total) {
|
|
|
index++;
|
|
|
List<Map<String, Object>> tempList = null;
|
|
|
- if (index * section < listXt.size()) {
|
|
|
+ if (index * section < total) {
|
|
|
tempList = listXt.subList((index - 1) * section, index * section);
|
|
|
} else {
|
|
|
- tempList = listXt.subList((index - 1) * section, listXt.size());
|
|
|
+ tempList = listXt.subList((index - 1) * section, total);
|
|
|
}
|
|
|
Map<String,Object>[] paramArray = tempList.toArray(new Map[tempList.size()]);
|
|
|
- daZongUtil.executeEnvironment("/train/saveOrUpdate", paramArray);
|
|
|
+ try {
|
|
|
+ daZongUtil.executeEnvironment("/train/saveOrUpdate", paramArray);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("重传火运实绩失败:第 " + index + " 片(" + tempList.size() + " 条)", e);
|
|
|
+ throw new Exception("重传中止:第 " + index + " 片(" + tempList.size() + " 条)推送失败,已成功 "
|
|
|
+ + successCount + " 条 / 共 " + total + " 条。失败原因:" + e.getMessage());
|
|
|
+ }
|
|
|
+ successCount += tempList.size();
|
|
|
}
|
|
|
+ //宏安(焦炭)走 /ha/train:需要时放开下面注释,参数与原接口一致
|
|
|
+ //List<Map<String, Object>> listHa = omsTransOrderMapper.getTrainResultForSend("宏安", startDate, endDate, busiType);
|
|
|
//while(index * section < listHa.size()) {
|
|
|
// index++;
|
|
|
// List<Map<String, Object>> tempList = null;
|
|
|
@@ -688,7 +717,8 @@ public class OmsTransOrderController extends BaseRESTfulController {
|
|
|
// Map<String,Object>[] paramArray = tempList.toArray(new Map[tempList.size()]);
|
|
|
// daZongUtil.executeEnvironment("/ha/train/saveOrUpdate", paramArray);
|
|
|
//}
|
|
|
- return success("OK");
|
|
|
+ return success("重传完成:传输类型 " + ("0".equals(busiType) ? "采购" : "销售")
|
|
|
+ + ",共 " + total + " 条,分 " + index + " 片推送成功");
|
|
|
}
|
|
|
|
|
|
|