|
|
@ -1,5 +1,7 @@ |
|
|
|
package com.logpm.warehouse.api; |
|
|
|
package com.logpm.warehouse.api; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
|
|
|
import com.logpm.basicdata.entity.BasicdataWarehouseEntity; |
|
|
|
import com.logpm.basicdata.entity.BasicdataWarehouseEntity; |
|
|
@ -23,10 +25,7 @@ import org.springblade.system.cache.DictBizCache; |
|
|
|
import org.springblade.system.entity.DictBiz; |
|
|
|
import org.springblade.system.entity.DictBiz; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.*; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Log4j2 |
|
|
|
@Log4j2 |
|
|
|
@RestController |
|
|
|
@RestController |
|
|
@ -1337,6 +1336,78 @@ public class WarehouseTrayTypeApiController { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
|
|
@PostMapping("/batchSyncOldTrayTypeInfo") |
|
|
|
|
|
|
|
@ApiOperationSupport(order = 1) |
|
|
|
|
|
|
|
@ApiOperation(value = "批量同步老系统托盘数据", notes = "传入trayTypeDTO") |
|
|
|
|
|
|
|
public R batchSyncOldTrayTypeInfo(@RequestBody TrayTypeDTO trayTypeDTO) { |
|
|
|
|
|
|
|
String method = "###########batchSyncOldTrayTypeInfo: "; |
|
|
|
|
|
|
|
log.info(method + "移托包件 trayTypeDTO={}", trayTypeDTO); |
|
|
|
|
|
|
|
String trayCodeStr = trayTypeDTO.getTrayCode(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); |
|
|
|
|
|
|
|
if(Objects.isNull(myCurrentWarehouse)){ |
|
|
|
|
|
|
|
log.warn(method+"仓库信息不能为空"); |
|
|
|
|
|
|
|
return R.fail(403,"仓库信息不能为空"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(StringUtil.isBlank(trayCodeStr)){ |
|
|
|
|
|
|
|
log.warn(method+"托盘码不能为空 trayCodeStr={}",trayCodeStr); |
|
|
|
|
|
|
|
return R.fail(403,"托盘码不能为空"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<String> trayCodes = new ArrayList<>(); |
|
|
|
|
|
|
|
if(trayCodeStr.contains(",")){ |
|
|
|
|
|
|
|
String[] split = trayCodeStr.split(","); |
|
|
|
|
|
|
|
trayCodes.addAll(Arrays.asList(split)); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
trayCodes.add(trayCodeStr); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (String trayCode : trayCodes) { |
|
|
|
|
|
|
|
log.info(method+"当前同步的托盘 trayCode={}",trayCode); |
|
|
|
|
|
|
|
R trayData = warehouseTrayTypeService.findTrayData(trayCode, myCurrentWarehouse.getId()); |
|
|
|
|
|
|
|
Object data = trayData.getData(); |
|
|
|
|
|
|
|
String s = JSONObject.toJSONString(data); |
|
|
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(s); |
|
|
|
|
|
|
|
JSONArray packageList = jsonObject.getJSONArray("packageList"); |
|
|
|
|
|
|
|
JSONArray zeroOrderList = jsonObject.getJSONArray("zeroOrderList"); |
|
|
|
|
|
|
|
JSONArray stockOrderList = jsonObject.getJSONArray("stockOrderList"); |
|
|
|
|
|
|
|
int packageSize = packageList.size(); |
|
|
|
|
|
|
|
int zeroSize = zeroOrderList.size(); |
|
|
|
|
|
|
|
int stockSize = stockOrderList.size(); |
|
|
|
|
|
|
|
int total = packageSize+zeroSize+stockSize; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R syncOldTrayData = warehouseTrayTypeService.findSyncOldTrayData(trayCode, myCurrentWarehouse.getId()); |
|
|
|
|
|
|
|
Object data1 = syncOldTrayData.getData(); |
|
|
|
|
|
|
|
String s1 = JSONObject.toJSONString(data1); |
|
|
|
|
|
|
|
JSONObject jsonObject1 = JSONObject.parseObject(s1); |
|
|
|
|
|
|
|
JSONArray packageList1 = jsonObject1.getJSONArray("packageList"); |
|
|
|
|
|
|
|
String trayType1 = jsonObject1.getString("trayType"); |
|
|
|
|
|
|
|
String trayCode1 = jsonObject1.getString("trayCode"); |
|
|
|
|
|
|
|
int size = packageList1.size(); |
|
|
|
|
|
|
|
if(total >= size){ |
|
|
|
|
|
|
|
log.warn(method+"新系统打托数量大于等于老系统 trayCode={} 不同步",trayCode); |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<String> orderPackageCodes = new ArrayList<>(); |
|
|
|
|
|
|
|
for (int i = 0; i < size; i++){ |
|
|
|
|
|
|
|
JSONObject jsonObject2 = packageList1.getJSONObject(i); |
|
|
|
|
|
|
|
orderPackageCodes.add(jsonObject2.getString("orderPackageCode")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
warehouseTrayTypeService.syncOldTrayData(trayCode1,trayType1,orderPackageCodes,myCurrentWarehouse.getId(),"同步老系统打托"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return R.success("处理完成"); |
|
|
|
|
|
|
|
}catch (CustomerException e){ |
|
|
|
|
|
|
|
log.warn(e.message); |
|
|
|
|
|
|
|
return R.fail(e.code,e.message); |
|
|
|
|
|
|
|
}catch (Exception e){ |
|
|
|
|
|
|
|
log.error(method+"系统异常,联系管理员",e); |
|
|
|
|
|
|
|
return R.fail(500,"系统异常,联系管理员"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|