//controller层转换的代码
@ApiOperation(value = "转换BO" , notes = "收货时更新库存")
@RequestMapping(value = "/app/v2/transferBO" , method = RequestMethod.POST)
public CommonTagInfoVO transferBO(@RequestBody @Valid CommonTagInfoBO bo){
// 参数校验
String warehouseCode = "D184";
Map<String, List<CTagInfoBO>> map = new HashMap<>();
for(CTagInfoBO tbo : bo.getTagskuInfos()){
if(ObjectUtils.isEmpty(map.get(tbo.getBarcode()))){
List<CTagInfoBO> ccList = new ArrayList<>();
ccList.add(tbo);
map.put(tbo.getBarcode(), ccList);
}else{
List<CTagInfoBO> cciList = map.get(tbo.getBarcode());
cciList.add(tbo);
map.put(tbo.getBarcode(), cciList);
}
}
List<CTagInfoExBO> ciList = new ArrayList<>();
for(String key : map.keySet()){
CTagInfoExBO ccbo = new CTagInfoExBO();
ccbo.setBarcode(key);
ccbo.setWarehousecode(warehouseCode);
List<String> epcList = new ArrayList<>();
for(CTagInfoBO cib : map.get(key)){
epcList.add(cib.getEpc());
}
ccbo.setEpcList(epcList);
ciList.add(ccbo);
}
CommonTagInfoVO vo = new CommonTagInfoVO();
vo.setRebindList(ciList);
return vo;
}
//几个要用的DTO
CommonTagInfoBO
@Getter
@Setter
public class CommonTagInfoBO {
private List<CTagInfoBO> tagskuInfos;
}
CommonTagInfoVO
@Getter
@Setter
public class CommonTagInfoVO {
private List<CTagInfoExBO> rebindList;
}
CTagInfoBO
@Getter
@Setter
public class CTagInfoBO {
private String barcode;
private boolean binded;
private String colorCode;
private String colorName;
private String epc;
private String productCode;
private String productName;
private boolean recyclable;
private String sizeCode;
private String sizeName;
}
CTagInfoExBO
@Getter
@Setter
public class CTagInfoExBO {
private String warehousecode;
private String barcode;
private List<String> epcList;
}