Commit 94662d07 authored by 曹盼盼's avatar 曹盼盼

修改管材校验

parent 084bedb0
package com.yeejoin.amos.boot.module.ugp.api.Enum;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
/**
* @Author cpp
* @Description
* @Date 2022/11/18
*/
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum ImageEnum {
JPG("jpg"),
JPEG("jpeg"),
GIF("gif"),
PNG ("png"),
BMP ("bmp"),
PSD ("psd");
private String name;
}
...@@ -169,8 +169,11 @@ public class MaterialServiceImpl extends BaseService<MaterialDto, Material, Mate ...@@ -169,8 +169,11 @@ public class MaterialServiceImpl extends BaseService<MaterialDto, Material, Mate
return jsonObject; return jsonObject;
} }
public Material getMaterial(Long materialId){ // 根据管材编号查询管材(管材编号必须唯一,报错一因为脏数据管材编号不唯一)
Material material = materialMapper.selectById(materialId); public Material getMaterial(String code){
LambdaQueryWrapper<Material> wrapper = new LambdaQueryWrapper<>( );
wrapper.eq(Material ::getCode,code);
Material material = materialMapper.selectOne(wrapper);
return material; return material;
} }
} }
\ No newline at end of file
...@@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.common.api.entity.OrgUsr; import com.yeejoin.amos.boot.module.common.api.entity.OrgUsr;
import com.yeejoin.amos.boot.module.ugp.api.Enum.ImageEnum;
import com.yeejoin.amos.boot.module.ugp.api.Enum.StageEnum; import com.yeejoin.amos.boot.module.ugp.api.Enum.StageEnum;
import com.yeejoin.amos.boot.module.ugp.api.Enum.VerifyEnum; import com.yeejoin.amos.boot.module.ugp.api.Enum.VerifyEnum;
...@@ -39,7 +40,11 @@ import org.springframework.stereotype.Service; ...@@ -39,7 +40,11 @@ import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import javax.imageio.ImageIO;
import java.awt.*; import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
...@@ -322,7 +327,7 @@ public class VerifyServiceImpl extends BaseService<VerifyDto,Verify,VerifyMapper ...@@ -322,7 +327,7 @@ public class VerifyServiceImpl extends BaseService<VerifyDto,Verify,VerifyMapper
Long welderId = orgService.getReginParams( ).getBusinessInfo( ).getUserSequenceNbr( ); Long welderId = orgService.getReginParams( ).getBusinessInfo( ).getUserSequenceNbr( );
Long random = jsonObject.getLong("random");//随机值 Long random = jsonObject.getLong("random");//随机值
Long projectId= jsonObject.getLong("projectId");//项目id Long projectId= jsonObject.getLong("projectId");//项目id
// Long welderId = jsonObject.getLong("welderId"); //焊工id //Long welderId = jsonObject.getLong("welderId"); //焊工id
String location = jsonObject.getString("location");//焊接定位信息 String location = jsonObject.getString("location");//焊接定位信息
String stage = jsonObject.getString("stage");//阶段检验 String stage = jsonObject.getString("stage");//阶段检验
Date time = new Date();// //获取当前校验时间 Date time = new Date();// //获取当前校验时间
...@@ -386,16 +391,18 @@ public class VerifyServiceImpl extends BaseService<VerifyDto,Verify,VerifyMapper ...@@ -386,16 +391,18 @@ public class VerifyServiceImpl extends BaseService<VerifyDto,Verify,VerifyMapper
if (stage.equals(StageEnum.焊前管材质量.getVerifyName())){ if (stage.equals(StageEnum.焊前管材质量.getVerifyName())){
//管材未校验,进行效验步骤 //管材未校验,进行效验步骤
Long materialId = jsonObject.getLong("materialId");//管材id // Long materialId = jsonObject.getLong("materialId");//管材id
//改为管材编号
String materialCode = jsonObject.getString("materialId");
verify.setStage(StageEnum.焊前管材质量.getStage()); verify.setStage(StageEnum.焊前管材质量.getStage());
/**校验*/ /**校验*/
Boolean flag =false; Boolean flag =false;
if (!ValidationUtil.isEmpty(materialId)) { if (!ValidationUtil.isEmpty(materialCode)) {
Material material = materialService.getMaterial(materialId); Material material = materialService.getMaterial(materialCode);
if (!ValidationUtil.isEmpty(material)) { if (!ValidationUtil.isEmpty(material)) {
jsonObject.put("valid","有效"); jsonObject.put("valid","有效");
jsonObject.put("accord","符合"); jsonObject.put("accord","符合");
flag = true;
if (StringUtils.isNotEmpty(material.getManufacturer())) { if (StringUtils.isNotEmpty(material.getManufacturer())) {
jsonObject.put("manufacturer",material.getManufacturer()); jsonObject.put("manufacturer",material.getManufacturer());
} }
...@@ -403,6 +410,7 @@ public class VerifyServiceImpl extends BaseService<VerifyDto,Verify,VerifyMapper ...@@ -403,6 +410,7 @@ public class VerifyServiceImpl extends BaseService<VerifyDto,Verify,VerifyMapper
jsonObject.put("batchNumber",material.getBatchNum()); jsonObject.put("batchNumber",material.getBatchNum());
} }
jsonObject.put("permission","合格期内"); jsonObject.put("permission","合格期内");
flag = true;
}else { }else {
jsonObject.put("valid","已超期"); jsonObject.put("valid","已超期");
...@@ -921,53 +929,65 @@ public class VerifyServiceImpl extends BaseService<VerifyDto,Verify,VerifyMapper ...@@ -921,53 +929,65 @@ public class VerifyServiceImpl extends BaseService<VerifyDto,Verify,VerifyMapper
if (welderId != null) { if (welderId != null) {
openDto.setDetailId(welderId); openDto.setDetailId(welderId);
//焊工的老照片 //焊工的老照片
Map map = orgService.getdetialInfo(welderId.toString( )); Map map = orgService.getdetialInfo(welderId.toString( ));
String image = map.get("image").toString(); if (!ValidationUtil.isEmpty(map)) {
String image =String.valueOf(map.get("image")) ;
if (StringUtils.isNotEmpty(image)) {
JSONArray jsonArray = JSONArray.parseArray(image); JSONArray jsonArray = JSONArray.parseArray(image);
if (jsonArray != null && jsonArray.size()>0) {
for (Object o : jsonArray) { for (Object o : jsonArray) {
JSONObject ob = JSONObject.parseObject(o.toString( )); JSONObject ob = JSONObject.parseObject(o.toString( ));
if (ob != null) {
String url = ob.getString("url"); String url = ob.getString("url");
if (!StringUtils.isEmpty(url)) { if (!StringUtils.isEmpty(url)) {
openDto.setOldPhoto(url); openDto.setOldPhoto(url);
} }
} }
} }
}
}
}
}
} }
if (StageEnum.焊前设备.getStage().equals(verify.getStage())) { if (StageEnum.焊前设备.getStage().equals(verify.getStage())) {
Long weldingId = object.getLong("weldingId"); Long weldingId = object.getLong("weldingId");
if (weldingId != null) { if (weldingId != null) {
openDto.setDetailId(weldingId); openDto.setDetailId(weldingId);
AttachmentDto enuipment = attachmentService.getAttachment(weldingId); String image = this.getImage(weldingId);
if (enuipment != null) { if (StringUtils.isNotEmpty(image)) {
String info = enuipment.getInfo( ); openDto.setOldPhoto(image);
if (StringUtils.isNotEmpty(info)) { }
JSONArray jsonArray = JSONArray.parseArray(info);
for (Object o : jsonArray) {
JSONObject object1 = JSONObject.parseObject(o.toString( ));
String info1 = object1.getString("info");
JSONArray jsonArray1 = JSONArray.parseArray(info1);
for (Object o1 : jsonArray1) {
JSONObject object2 = JSONObject.parseObject(o1.toString( ));
String url = object2.getString("url");
if (StringUtils.isNotEmpty(url)) {
openDto.setOldPhoto(url);
} }
} }
if (StageEnum.焊前管材质量.getStage().equals(verify.getStage())) {
Long materialId = object.getLong("materialId");
if (materialId != null) {
openDto.setDetailId(materialId);
String image = this.getImage(materialId);
if (StringUtils.isNotEmpty(image)) {
openDto.setOldPhoto(image);
} }
} }
} }
} }
ArrayList<OpenDto> list = new ArrayList<>( );
list.add(openDto);
return list ;
} }
if (StageEnum.焊前管材质量.getStage().equals(verify.getStage())) {
Long materialId = object.getLong("materialId"); // 图片公共方法
if (materialId != null) { public String getImage(Long id){
openDto.setDetailId(materialId); String oldPhoto =null;
AttachmentDto enuipment = attachmentService.getAttachment(materialId); if (id != null) {
AttachmentDto enuipment = attachmentService.getAttachment(id);
if (enuipment != null) { if (enuipment != null) {
String info = enuipment.getInfo( ); String info = enuipment.getInfo( );
if (StringUtils.isNotEmpty(info)) { if (StringUtils.isNotEmpty(info)) {
...@@ -978,24 +998,25 @@ public class VerifyServiceImpl extends BaseService<VerifyDto,Verify,VerifyMapper ...@@ -978,24 +998,25 @@ public class VerifyServiceImpl extends BaseService<VerifyDto,Verify,VerifyMapper
JSONArray jsonArray1 = JSONArray.parseArray(info1); JSONArray jsonArray1 = JSONArray.parseArray(info1);
for (Object o1 : jsonArray1) { for (Object o1 : jsonArray1) {
JSONObject object2 = JSONObject.parseObject(o1.toString( )); JSONObject object2 = JSONObject.parseObject(o1.toString( ));
String url = object2.getString("url"); oldPhoto= object2.getString("url");
if (StringUtils.isNotEmpty(url)) { if (StringUtils.isNotEmpty(oldPhoto)) {
openDto.setOldPhoto(url);
} String[] split = oldPhoto.split(".");
//不区分大小写.jpe .JPE,需要转换成小写写
String suffix = split[split.length - 1].toLowerCase( );
if (suffix.contains(ImageEnum.GIF.getName()) || suffix.contains(ImageEnum.PNG.getName()) ||
suffix.contains(ImageEnum.JPG.getName()) || suffix.contains(ImageEnum.JPEG.getName()) ||
suffix.contains(ImageEnum.BMP.getName()) || suffix.contains(ImageEnum.PSD.getName())) {
return oldPhoto;
} }
} }
} }
} }
} }
} }
} }
ArrayList<OpenDto> list = new ArrayList<>( ); return oldPhoto;
list.add(openDto);
return list ;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment