|
|
|
@ -16,6 +16,7 @@ import com.dreamchaser.depository_manage.mapper.ConstructionUnitMapper; |
|
|
|
import com.dreamchaser.depository_manage.mapper.DepositoryRecordMapper; |
|
|
|
import com.dreamchaser.depository_manage.mapper.MaterialMapper; |
|
|
|
import com.dreamchaser.depository_manage.security.pool.ExcelFileInfoPool; |
|
|
|
import com.dreamchaser.depository_manage.security.pool.HandlesOtherFunctionalThreadPool; |
|
|
|
import com.dreamchaser.depository_manage.service.*; |
|
|
|
import com.dreamchaser.depository_manage.utils.*; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
@ -746,7 +747,7 @@ public class ExcelServiceImpl implements ExcelService { |
|
|
|
} |
|
|
|
} |
|
|
|
ExcelFileInfoPool.removeUserExcelInventoryInfo(number); |
|
|
|
log.info("【批量添加】批量添加数据:{}", JSON.toJSONString(excelVosForInventory) + ";导入人员" + userByPort.getName() + ":" + userByPort.getNumber() + ";导入总数为:" + successCount+",导入时间为: "+DateUtil.getNowTime()); |
|
|
|
log.info("【批量添加】批量添加数据:{}", JSON.toJSONString(excelVosForInventory) + ";导入人员" + userByPort.getName() + ":" + userByPort.getNumber() + ";导入总数为:" + successCount + ",导入时间为: " + DateUtil.getNowTime()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -787,7 +788,7 @@ public class ExcelServiceImpl implements ExcelService { |
|
|
|
|
|
|
|
} |
|
|
|
ExcelFileInfoPool.removeUserExcelMaterialTypeInfo(number); |
|
|
|
log.info("【批量添加】批量添加数据:{}", JSON.toJSONString(excelVosForMaterialType) + ";导入人员" + userByPort.getName() + ":" + userByPort.getNumber() + ";导入总数" + successNum+",导入时间为: "+DateUtil.getNowTime()); |
|
|
|
log.info("【批量添加】批量添加数据:{}", JSON.toJSONString(excelVosForMaterialType) + ";导入人员" + userByPort.getName() + ":" + userByPort.getNumber() + ";导入总数" + successNum + ",导入时间为: " + DateUtil.getNowTime()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@ -847,10 +848,63 @@ public class ExcelServiceImpl implements ExcelService { |
|
|
|
} |
|
|
|
} |
|
|
|
ExcelFileInfoPool.removeUserExcelMaterialInfo(number); |
|
|
|
log.info("【批量添加】批量添加数据:{}", JSON.toJSONString(excelVosForMaterial) + ";导入人员" + userByPort.getName() + ":" + userByPort.getNumber() + ";导入总数" + successNum+",导入时间为: "+DateUtil.getNowTime()); |
|
|
|
log.info("【批量添加】批量添加数据:{}", JSON.toJSONString(excelVosForMaterial) + ";导入人员" + userByPort.getName() + ":" + userByPort.getNumber() + ";导入总数" + successNum + ",导入时间为: " + DateUtil.getNowTime()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 用于执行物料覆盖方法 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void executeOverwriteForMaterial(UserByPort userByPort) { |
|
|
|
List<Object> success = new ArrayList<>(); |
|
|
|
String number = userByPort.getNumber(); |
|
|
|
List<ExcelInfoForMaterial> excelMaterialInfoByOverwrite = ExcelFileInfoPool.getUserExcelMaterialInfoByOverwrite(number); |
|
|
|
List<ExcelInfoForMaterial> userExcelMaterialInfo = ExcelFileInfoPool.getUserExcelMaterialInfo(number); |
|
|
|
if(userExcelMaterialInfo != null && userExcelMaterialInfo.size() > 0){ |
|
|
|
// 如果有需要导入的数据
|
|
|
|
HandlesOtherFunctionalThreadPool.execute(()->{ |
|
|
|
// 开启一个线程去执行导入方法
|
|
|
|
executeImportForMaterial(userByPort); |
|
|
|
}); |
|
|
|
} |
|
|
|
int successNum = 0; |
|
|
|
for (int i = 0; i < excelMaterialInfoByOverwrite.size(); i++) { |
|
|
|
ExcelInfoForMaterial excelVo = excelMaterialInfoByOverwrite.get(i); |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
String code = excelVo.getCode(); |
|
|
|
if (code != null && !"".equals(code)) { |
|
|
|
map.put("mcode", code); |
|
|
|
} else { |
|
|
|
map.put("mname", excelVo.getMname()); |
|
|
|
map.put("version", excelVo.getVersion()); |
|
|
|
} |
|
|
|
String price = excelVo.getPrice(); |
|
|
|
if (price != null && !"".equals(price)) { |
|
|
|
map.put("price", (int)(ObjectFormatUtil.toDouble(price) * 100)); |
|
|
|
} else { |
|
|
|
map.put("price", 0); |
|
|
|
} |
|
|
|
map.put("uid", userByPort.getId()); |
|
|
|
map.put("updateTime", System.currentTimeMillis()); |
|
|
|
successNum += materialMapper.updateMaterialForImport(map); |
|
|
|
success.add(excelVo); |
|
|
|
|
|
|
|
if ((i + 1) % 100 == 0 || excelMaterialInfoByOverwrite.size() - 1 == i) { |
|
|
|
// 如果凑够100条或者已经循环完成 发送消息
|
|
|
|
try { |
|
|
|
WebSocketController.sendInfo(JSONObject.toJSONString(success), number); |
|
|
|
success = new ArrayList<>(); |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
ExcelFileInfoPool.removeUserExcelMaterialInfoByOverwrite(number); |
|
|
|
log.info("【批量添加】批量修改数据:{}", JSON.toJSONString(excelMaterialInfoByOverwrite) + ";导入人员" + userByPort.getName() + ":" + userByPort.getNumber() + ";导入总数" + successNum + ",导入时间为: " + DateUtil.getNowTime()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 用于清空导入的数据 |
|
|
|
*/ |
|
|
|
@ -858,6 +912,7 @@ public class ExcelServiceImpl implements ExcelService { |
|
|
|
ExcelFileInfoPool.removeUserExcelInventoryInfo(userByPort.getNumber()); |
|
|
|
ExcelFileInfoPool.removeUserExcelMaterialInfo(userByPort.getNumber()); |
|
|
|
ExcelFileInfoPool.removeUserExcelMaterialTypeInfo(userByPort.getNumber()); |
|
|
|
ExcelFileInfoPool.removeUserExcelMaterialInfoByOverwrite(userByPort.getNumber()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -1080,6 +1135,9 @@ public class ExcelServiceImpl implements ExcelService { |
|
|
|
String s = dataIndex.get(i); |
|
|
|
String msg = s + "出现异常,名称为:" + mname + ",型号为:" + excelInfoForMaterial.getVersion() + "的物料已存在"; |
|
|
|
errMsg.add(msg); |
|
|
|
// 添加一条数据用于覆盖
|
|
|
|
ExcelFileInfoPool.addExcelMaterialInfoByOverwrite(userByPort.getNumber(), excelInfoForMaterial); |
|
|
|
log.info("要覆盖的数据" + JSONObject.toJSONString(excelInfoForMaterial)); |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (excelInfoForMaterial.getCode() != null) { |
|
|
|
@ -1087,6 +1145,9 @@ public class ExcelServiceImpl implements ExcelService { |
|
|
|
if (materialByCode != null) { |
|
|
|
String s = dataIndex.get(i); |
|
|
|
String msg = s + "出现异常,编码为:" + excelInfoForMaterial.getCode() + "的物料已存在"; |
|
|
|
// 添加一条数据用于覆盖
|
|
|
|
ExcelFileInfoPool.addExcelMaterialInfoByOverwrite(userByPort.getNumber(), excelInfoForMaterial); |
|
|
|
log.info("要覆盖的数据" + JSONObject.toJSONString(excelInfoForMaterial)); |
|
|
|
errMsg.add(msg); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|