add:导入工单添加错误文件提醒

This commit is contained in:
zhangzhiqiang
2023-06-14 08:45:38 +08:00
parent e87527d7f7
commit 5ee636414a
4 changed files with 58 additions and 51 deletions

View File

@@ -17,7 +17,7 @@ public class CodeUtil{
String codeId = service.queryIdByCode(ruleCode);
RedissonUtils.lock(() -> {
code[0] = service.codeDemo(map);
}, codeId, 3);
}, codeId, 1);
return code[0];
}
}

View File

@@ -206,8 +206,9 @@ public class SpeEmpTask extends AbstractAcsTask {
if (!("fall_finish"+task.getTask_id()).equals(device.getRemark())){
iDeviceService.update(new UpdateWrapper<PdmBiDevice>()
.set("material_id", task.getMaterial_id())
.set("deviceinstor_qty",device.getDeviceinstor_qty().add(task.getMaterial_qty()))
.set("remark","fall_finish"+task.getTask_id())
.eq("device_code", task.getPoint_code2()));
.eq("device_code", device.getDevice_code()));
}
}
break;

View File

@@ -171,34 +171,18 @@ public class SpeFullTask extends AbstractAcsTask {
.set("update_name","acs")
.set("update_time",DateUtil.now()).eq("task_id",task.getTask_id()));
Map<String, String> extParam = (Map)param.get("ext_param");
//取货完成/放货完成暂不处理箱子
if (extParam.get("put_finish") != null){
log.info("放货完成:{},vechile_code:{}",task.getTask_id(),task.getVehicle_code2());
// pointService.update(new UpdateWrapper<SchBasePoint>()
// .set("vehicle_code",task.getVehicle_code2())
// .eq("point_code",task.getPoint_code3()));
}
//take_finish 取满 fall_finish 倒料 put_finish放空
if (extParam.get("fall_finish") != null){
PdmBiDevice one = deviceService.getOne(new QueryWrapper<PdmBiDevice>().eq("device_code", task.getPoint_code2()));
//TODO:添加任务唯一性校验防止重复更新
PdmBiDevice one = deviceService.getDeviceByPointCode(task.getPoint_code2());
if (!("fall_finish"+task.getTask_id()).equals(one.getRemark())){
deviceService.update(new UpdateWrapper<PdmBiDevice>()
.set("material_id", task.getMaterial_id())
.set("deviceinstor_qty",one.getDeviceinstor_qty().add(task.getMaterial_qty()))
.set("remark","fall_finish"+task.getTask_id())
.eq("device_code", task.getPoint_code2()));
.eq("device_code", one.getDevice_code()));
}
}
if (extParam.get("take_finish") != null){
log.info("取货完成:{},vechile_code:{}",task.getTask_id(),task.getVehicle_code2());
// pointService.update(new UpdateWrapper<SchBasePoint>()
// .set("vehicle_code","")
// .eq("point_code",task.getPoint_code3()));
// pointService.update(new UpdateWrapper<SchBasePoint>()
// .set("vehicle_code",task.getVehicle_code2())
// .eq("point_code",task.getPoint_code1()));
}
break;
case STATUS_FINISH:
taskService.update(new UpdateWrapper<SchBaseTask>()

View File

@@ -254,12 +254,14 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
// 循环获取的数据
List<PdmProduceWorkorder> data = new ArrayList<>();
Map<String, String> errorMap = new HashMap();
List<String> workprodures = new ArrayList<>();
List<String> materialSpecs = new ArrayList<>();
List<String> persons = new ArrayList<>();
row:
for (int i = 0; i < read.size(); i++) {
List<Object> list = read.get(i);
if (ObjectUtil.isEmpty(list)) {
continue;
}
if (ObjectUtil.isEmpty(list)) { continue; }
PdmProduceWorkorder workorder = new PdmProduceWorkorder();
packageForm(workorder);
for (int j = 0; j < list.size(); j++) {
@@ -284,26 +286,12 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
}
if (j == 2) {
//物料
List<MdMeMaterialbase> material_specs = materialbaseService.list(new QueryWrapper<MdMeMaterialbase>().eq("material_spec", col));
if (CollectionUtils.isEmpty(material_specs)) {
errorMap.put("" + (i + 1) + "行,第" + (j + 1) + "", col + "物料规格对应物料信息不存在");
} else {
Optional<MdMeMaterialbase> first = material_specs.stream().filter(mdMeMaterialbase -> mdMeMaterialbase.getMaterial_code().contains("S")
&& Pattern.matches("^[0-9]*$", mdMeMaterialbase.getMaterial_name().substring(mdMeMaterialbase.getMaterial_name().length() - 1))
).findFirst();
if (!first.isPresent()) {
errorMap.put("" + (i + 1) + "行,第" + (j + 1) + "", col + "物料规格对应物料信息不存在");
}
workorder.setMaterial_id(first.get().getMaterial_id());
}
materialSpecs.add(col);
workorder.setMaterial_id(col);
}
if (j == 3) {
PdmBiWorkprocedure workprocedure = workprocedureService.getOne(new QueryWrapper<PdmBiWorkprocedure>().eq("workprocedure_name", col));
if (ObjectUtil.isEmpty(workprocedure)) {
errorMap.put("" + (i + 1) + "行,第" + (j + 1) + "", col + "工序名称是否正确");
} else {
workorder.setWorkprocedure_id(workprocedure.getWorkprocedure_id());
}
workprodures.add(col);
workorder.setWorkprocedure_id(col);
}
if (j == 4) {
//设备 A1_TW_
@@ -315,13 +303,8 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
workorder.setMaterial_weight(bigDecimal.setScale(3, RoundingMode.HALF_UP));
}
if (j == 8) {
//操作工
SysUser user = userService.getOne(new QueryWrapper<SysUser>().eq("person_name", col));
if (ObjectUtil.isEmpty(user)) {
errorMap.put("" + (i + 1) + "行,第" + (j + 1) + "", col + " 操作工没有账号");
} else {
workorder.setCurrent_produce_person_id(user.getUser_id());
}
persons.add(col);
workorder.setCurrent_produce_person_id(col);
}
if (j == 9) {
workorder.setPlan_qty(new BigDecimal(Long.valueOf(col)));
@@ -334,7 +317,46 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
if (CollectionUtils.isEmpty(errorMap)) {
data.add(workorder);
}
;
}
List<MdMeMaterialbase> tmp_material_specs = materialbaseService.list(new QueryWrapper<MdMeMaterialbase>().in("material_spec", materialSpecs));
List<SysUser> tmp_sysUsers = userService.list(new QueryWrapper<SysUser>().in("person_name", persons));
List<PdmBiWorkprocedure> tmp_workprocedure_names = workprocedureService.list(new QueryWrapper<PdmBiWorkprocedure>().in("workprocedure_name", workprodures));
Map<String, PdmBiWorkprocedure> collect = tmp_workprocedure_names.stream().collect(HashMap::new, (k, v) -> k.put(v.getWorkprocedure_name(), v), HashMap::putAll);
Map<String, SysUser> users = tmp_sysUsers.stream().collect(HashMap::new, (k, v) -> k.put(v.getPerson_name(), v), HashMap::putAll);
Map<String, List<MdMeMaterialbase>> materialspecs = tmp_material_specs.stream().collect(Collectors.groupingBy(MdMeMaterialbase::getMaterial_spec));
for (int i = 0; i < data.size(); i++) {
PdmProduceWorkorder workorder = data.get(i);
SysUser sysUser = users.get(workorder.getCurrent_produce_person_id());
if (sysUser==null){
errorMap.put(""+(i+1)+"行:","账号:"+workorder.getCurrent_produce_person_id()+"不存在");
}else {
workorder.setCurrent_produce_person_id(sysUser.getUser_id());
}
PdmBiWorkprocedure workprocedure = collect.get(workorder.getWorkprocedure_id());
if (workprocedure==null){
errorMap.put(""+(i+1)+"行:","工序名称:"+workorder.getWorkprocedure_id()+"不存在");
}else {
workorder.setWorkorder_id(workprocedure.getWorkprocedure_id());
}
List<MdMeMaterialbase> mdMeMaterialbases = materialspecs.get(workorder.getMaterial_id());
if (!CollectionUtils.isEmpty(mdMeMaterialbases)){
if (mdMeMaterialbases.size() == 1){
workorder.setMaterial_id(mdMeMaterialbases.get(0).getMaterial_id());
}else {
Optional<MdMeMaterialbase> first = mdMeMaterialbases.stream().filter(mdMeMaterialbase -> mdMeMaterialbase.getMaterial_code().contains("S")
&& Pattern.matches("^[0-9]*$", mdMeMaterialbase.getMaterial_name().substring(mdMeMaterialbase.getMaterial_name().length() - 1))
).findFirst();
if (first.isPresent()){
workorder.setMaterial_id(first.get().getMaterial_id());
}else {
errorMap.put(""+(i+1)+"行:","物料规格:"+workorder.getMaterial_id()+"不存在");
}
}
}else {
errorMap.put(""+(i+1)+"行:","物料规格:"+workorder.getMaterial_id()+"不存在");
}
}
if (!CollectionUtils.isEmpty(errorMap)) {
throw new BadRequestException(JSON.toJSONString(errorMap));