Merge branch 'master' of http://121.40.234.130:8899/root/hl_one
This commit is contained in:
@@ -173,6 +173,12 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
if (workorders.size()!= ids.size()){
|
||||
throw new BadRequestException("完成的工单不允许再次下发");
|
||||
}
|
||||
this.update(new UpdateWrapper<PdmProduceWorkorder>()
|
||||
.set("workorder_status", WorkerOrderEnum.SEND.getCode())
|
||||
.set("down_id", SecurityUtils.getCurrentUserId())
|
||||
.set("down_name", SecurityUtils.getCurrentNickName())
|
||||
.set("down_time", new Date())
|
||||
.in("workorder_id", ids));
|
||||
this.recordWorkOrder(OptionRecord.OptionEnum.UPDATE, ids.toArray(new String[0]));
|
||||
|
||||
}
|
||||
@@ -247,120 +253,14 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
inputStream = file.getInputStream();
|
||||
//A1_TW_+device_code 日期2023/5/30
|
||||
//material_spec='24030921S'
|
||||
ExcelReader excelReader = ExcelUtil.getReader(inputStream, "推弯计划表");
|
||||
List<List<Object>> read = excelReader.read();
|
||||
// 循环获取的数据
|
||||
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; }
|
||||
PdmProduceWorkorder workorder = new PdmProduceWorkorder();
|
||||
packageForm(workorder);
|
||||
for (int j = 0; j < list.size(); j++) {
|
||||
String col = String.valueOf(list.get(j));
|
||||
解析cell:
|
||||
{ //如果是第一行 为生产日期
|
||||
if (i == 0 && j == 0) {
|
||||
continue row;
|
||||
}
|
||||
//如果第一列包含规格二字 则为表头 结束内循环列
|
||||
if (j == 0 && col.contains("班次")) {
|
||||
continue row;
|
||||
}
|
||||
if (j == 0) {
|
||||
//物料
|
||||
workorder.setShift_type_scode(col.equals("晚班") ? "2" : "1");
|
||||
}
|
||||
if (j == 1) {
|
||||
//物料
|
||||
workorder.setPlanproduceend_date(col.substring(0, col.indexOf(" ")) + " 18:30:00");
|
||||
workorder.setPlanproducestart_date(col.substring(0, col.indexOf(" ")) + " 07:30:00");
|
||||
}
|
||||
if (j == 2) {
|
||||
//物料
|
||||
materialSpecs.add(col);
|
||||
workorder.setMaterial_id(col);
|
||||
}
|
||||
if (j == 3) {
|
||||
workprodures.add(col);
|
||||
workorder.setWorkprocedure_id(col);
|
||||
}
|
||||
if (j == 4) {
|
||||
//设备 A1_TW_
|
||||
workorder.setDevice_code("A1_TW_" + col.replaceAll("-", "_"));
|
||||
}
|
||||
if (j == 7) {
|
||||
//单重
|
||||
BigDecimal bigDecimal = BigDecimal.valueOf(Double.valueOf(col) * 1000);
|
||||
workorder.setMaterial_weight(bigDecimal.setScale(3, RoundingMode.HALF_UP));
|
||||
}
|
||||
if (j == 8) {
|
||||
persons.add(col);
|
||||
workorder.setCurrent_produce_person_id(col);
|
||||
}
|
||||
if (j == 9) {
|
||||
workorder.setPlan_qty(new BigDecimal(Long.valueOf(col)));
|
||||
}
|
||||
if (j == 13) {
|
||||
workorder.setIs_needmove(col.equals("是") ? true : false);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isEmpty(errorMap)) {
|
||||
data.add(workorder);
|
||||
}
|
||||
String name = file.getOriginalFilename();
|
||||
if (name.contains("推弯")){
|
||||
推弯(inputStream);
|
||||
}
|
||||
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));
|
||||
} else {
|
||||
this.saveBatch(data);
|
||||
if (name.contains("综合")){
|
||||
综合(inputStream);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new BadRequestException(e.getMessage());
|
||||
@@ -375,6 +275,279 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
|
||||
}
|
||||
|
||||
private void 推弯(InputStream inputStream) {
|
||||
ExcelReader excelReader = ExcelUtil.getReader(inputStream, "推弯计划表");
|
||||
List<List<Object>> read = excelReader.read();
|
||||
// 循环获取的数据
|
||||
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; }
|
||||
PdmProduceWorkorder workorder = new PdmProduceWorkorder();
|
||||
packageForm(workorder);
|
||||
for (int j = 0; j < list.size(); j++) {
|
||||
String col = String.valueOf(list.get(j));
|
||||
解析cell:
|
||||
{ //如果是第一行 为生产日期
|
||||
if (i == 0 && j == 0) {
|
||||
continue row;
|
||||
}
|
||||
//如果第一列包含规格二字 则为表头 结束内循环列
|
||||
if (j == 0 && col.contains("班次")) {
|
||||
continue row;
|
||||
}
|
||||
if (j == 0) {
|
||||
//物料
|
||||
workorder.setShift_type_scode(col.equals("晚班") ? "2" : "1");
|
||||
}
|
||||
if (j == 1) {
|
||||
//物料
|
||||
workorder.setPlanproduceend_date(col.substring(0, col.indexOf(" ")) + " 18:30:00");
|
||||
workorder.setPlanproducestart_date(col.substring(0, col.indexOf(" ")) + " 07:30:00");
|
||||
}
|
||||
if (j == 2) {
|
||||
//物料
|
||||
materialSpecs.add(col);
|
||||
workorder.setMaterial_id(col);
|
||||
}
|
||||
if (j == 3) {
|
||||
workprodures.add(col);
|
||||
workorder.setWorkprocedure_id(col);
|
||||
}
|
||||
if (j == 4) {
|
||||
//设备 A1_TW_
|
||||
workorder.setDevice_code("A1_TW_" + col.replaceAll("-", "_"));
|
||||
}
|
||||
if (j == 7) {
|
||||
//单重
|
||||
BigDecimal bigDecimal = BigDecimal.valueOf(Double.valueOf(col) * 1000);
|
||||
workorder.setMaterial_weight(bigDecimal.setScale(3, RoundingMode.HALF_UP));
|
||||
}
|
||||
if (j == 8) {
|
||||
persons.add(col);
|
||||
workorder.setCurrent_produce_person_id(col);
|
||||
}
|
||||
if (j == 9) {
|
||||
workorder.setPlan_qty(new BigDecimal(Long.valueOf(col)));
|
||||
}
|
||||
if (j == 13) {
|
||||
workorder.setIs_needmove(col.equals("是") ? true : false);
|
||||
}
|
||||
if (j == 14) {
|
||||
workorder.setRemark(col);
|
||||
}
|
||||
}
|
||||
}
|
||||
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));
|
||||
} else {
|
||||
this.saveBatch(data);
|
||||
}
|
||||
}
|
||||
private void 综合(InputStream inputStream) {
|
||||
ExcelReader excelReader = ExcelUtil.getReader(inputStream, 0);
|
||||
List<List<Object>> read = excelReader.read();
|
||||
// 循环获取的数据
|
||||
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; }
|
||||
PdmProduceWorkorder workorder = new PdmProduceWorkorder();
|
||||
packageForm(workorder);
|
||||
for (int j = 0; j < list.size(); j++) {
|
||||
String col = String.valueOf(list.get(j));
|
||||
解析cell:
|
||||
{ //如果是第一行 为生产日期
|
||||
if (i == 0 && j == 0) {
|
||||
continue row;
|
||||
}
|
||||
//如果第一列包含规格二字 则为表头 结束内循环列
|
||||
if (j == 0 && col.contains("班次")) {
|
||||
continue row;
|
||||
}
|
||||
if (j == 0) {
|
||||
workorder.setShift_type_scode(col.equals("晚班") ? "2" : "1");
|
||||
}
|
||||
if (j == 1) {
|
||||
if (workorder.getShift_type_scode().equals("1")){
|
||||
workorder.setPlanproduceend_date(col.substring(0, col.indexOf(" ")) + " 18:30:00");
|
||||
workorder.setPlanproducestart_date(col.substring(0, col.indexOf(" ")) + " 07:30:00");
|
||||
}else {
|
||||
workorder.setPlanproducestart_date(col.substring(0, col.indexOf(" ")) + " 18:30:00");
|
||||
workorder.setPlanproduceend_date(col.substring(0, col.indexOf(" ")) + " 07:30:00");
|
||||
}
|
||||
}
|
||||
if (j == 2) {
|
||||
//物料
|
||||
materialSpecs.add(col);
|
||||
workorder.setMaterial_id(col);
|
||||
}
|
||||
if (j == 4) {
|
||||
workprodures.add(col);
|
||||
workorder.setWorkprocedure_id(col);
|
||||
}
|
||||
if (j == 5) {
|
||||
//设备 A1_TW_
|
||||
workorder.setDevice_code(col);
|
||||
}
|
||||
if (j == 8) {
|
||||
//单重
|
||||
BigDecimal bigDecimal = BigDecimal.valueOf(Double.valueOf(col) * 1000);
|
||||
workorder.setMaterial_weight(bigDecimal.setScale(3, RoundingMode.HALF_UP));
|
||||
}
|
||||
if (j == 9) {
|
||||
persons.add(col);
|
||||
workorder.setCurrent_produce_person_id(col);
|
||||
}
|
||||
if (j == 10) {
|
||||
workorder.setPlan_qty(new BigDecimal(Long.valueOf(col)));
|
||||
}
|
||||
if (j == 14) {
|
||||
workorder.setIs_needmove(col.equals("是") ? true : false);
|
||||
}
|
||||
if (j == 15) {
|
||||
workorder.setRemark(col);
|
||||
}
|
||||
}
|
||||
}
|
||||
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.setWorkprocedure_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));
|
||||
} else {
|
||||
List<String> workprocedures = data.stream().map(PdmProduceWorkorder::getWorkprocedure_id).collect(Collectors.toList());
|
||||
List<PdmBiDevice> list = deviceService.list(new QueryWrapper<PdmBiDevice>()
|
||||
.in("workprocedure_id", workprocedures)
|
||||
);
|
||||
Map<String, List<PdmBiDevice>> listMap = list.stream().collect(Collectors.groupingBy(PdmBiDevice::getWorkprocedure_id));
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
PdmProduceWorkorder item = data.get(i);
|
||||
List<PdmBiDevice> devices = listMap.get(item.getWorkprocedure_id());
|
||||
if (item.getWorkprocedure_id().equals("1535144356586165920")){
|
||||
item.setDevice_code("A1_DC_" + item.getDevice_code().replaceAll("-", "_"));
|
||||
}else if (item.getWorkprocedure_id().equals("1535143882327724032")){
|
||||
item.setDevice_code("A1_XY_" + item.getDevice_code().replaceAll("-", "_"));
|
||||
} else {
|
||||
List<PdmBiDevice> deviceCollect = devices.stream().filter(pdmBiDevice -> {
|
||||
String device_code = pdmBiDevice.getDevice_code();
|
||||
int indexOf = device_code.lastIndexOf("_");
|
||||
String substring = device_code.substring(indexOf+1);
|
||||
return Integer.valueOf(substring).equals(Integer.valueOf(item.getDevice_code()));
|
||||
}).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(deviceCollect) || deviceCollect.size()>1){
|
||||
errorMap.put("第"+(i+1)+"行:","设备名称:"+item.getDevice_code()+"不存在了!!");
|
||||
}else {
|
||||
item.setDevice_code(deviceCollect.get(0).getDevice_code());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!CollectionUtils.isEmpty(errorMap)) {
|
||||
throw new BadRequestException(JSON.toJSONString(errorMap));
|
||||
}else {
|
||||
this.saveBatch(data);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void packageForm(PdmProduceWorkorder workorder) {
|
||||
workorder.setWorkorder_id(IdUtil.getStringId());
|
||||
workorder.setWorkorder_code(CodeUtil.getNewCode("PDM_SHIFTORDER"));
|
||||
|
||||
Reference in New Issue
Block a user