Commit bc17d58b by 宋祥

Merge branch 'dev-sx' of http://git.pseer.com/platform/hp-smart into dev

 Conflicts:
	src/main/java/com/baosight/hpjx/hp/sc/domain/HPSC003.java
	src/main/java/com/baosight/hpjx/hp/sc/sql/HPSC003.xml
parents f0b57a61 2ecc4e1d
...@@ -167,6 +167,18 @@ ...@@ -167,6 +167,18 @@
<artifactId>oss-plugin</artifactId> <artifactId>oss-plugin</artifactId>
<version>7.0.0</version> <version>7.0.0</version>
</dependency> </dependency>
<!-- 二维码 -->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.27</version>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>3.5.3</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
package com.baosight.hpjx.controller; package com.baosight.hpjx.controller;
import com.baosight.hpjx.hp.mt.untils.Base64ToMultipartFile; import com.baosight.hpjx.core.utils.QrCodeUtils;
import com.baosight.hpjx.hp.mt.untils.UploadUtils2; import com.baosight.hpjx.hp.mt.untils.UploadUtils2;
import com.baosight.hpjx.util.FileUtils;
import com.baosight.hpjx.util.LogUtils; import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.MapUtils;
import com.baosight.hpjx.util.StringUtils;
import com.baosight.iplat4j.core.ei.EiConstant; import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo; import org.springframework.data.repository.query.Param;
import com.baosight.iplat4j.core.exception.PlatException; import org.springframework.web.bind.annotation.CrossOrigin;
import com.baosight.iplat4j.core.service.soa.XServiceManager; import org.springframework.web.bind.annotation.RequestMapping;
import com.baosight.iplat4j.eu.dm.document.bos.s3.api.signed.SignedBosHelp; import org.springframework.web.bind.annotation.RequestMethod;
import com.baosight.iplat4j.eu.dm.document.bos.s3.param.BosParamHelp; import org.springframework.web.bind.annotation.RestController;
import com.google.common.base.Joiner;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile; import org.springframework.web.multipart.commons.CommonsMultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Set;
import net.sf.json.JSONObject;
/** /**
* @author:songx * @author:songx
...@@ -51,7 +38,7 @@ public class FileUploadController { ...@@ -51,7 +38,7 @@ public class FileUploadController {
Map resultMap = new HashMap(); Map resultMap = new HashMap();
try { try {
JSONObject upload = UploadUtils2.upload((CommonsMultipartFile)file); JSONObject upload = UploadUtils2.upload((CommonsMultipartFile)file);
resultMap.put("id",upload.getString("docId")); resultMap.put("id", upload.getString("docId"));
resultMap.put("status", EiConstant.STATUS_SUCCESS); resultMap.put("status", EiConstant.STATUS_SUCCESS);
resultMap.put("message", "SUCCESS"); resultMap.put("message", "SUCCESS");
return resultMap; return resultMap;
...@@ -61,4 +48,22 @@ public class FileUploadController { ...@@ -61,4 +48,22 @@ public class FileUploadController {
return resultMap; return resultMap;
} }
} }
/**
* @param content
* @return
* @throws IOException
*/
@RequestMapping(value = "/createQrCode", method = RequestMethod.GET)
public Map<String, Object> createQrCode(@Param("content") String content) {
try {
return QrCodeUtils.create(content);
} catch (Exception e) {
Map resultMap = new HashMap();
resultMap.put("status", 500);
resultMap.put("message", LogUtils.getMsg(e));
return resultMap;
}
}
} }
...@@ -36,4 +36,9 @@ public class OSConstant { ...@@ -36,4 +36,9 @@ public class OSConstant {
*/ */
public final static String DOWN_DIR = USER_DIR + SEPARATOR + "download"; public final static String DOWN_DIR = USER_DIR + SEPARATOR + "download";
/**
* 二维码目录
*/
public final static String QRCODE_DIR = USER_DIR + SEPARATOR + "qrcode";
} }
package com.baosight.hpjx.core.utils;
import com.baosight.hpjx.core.constant.OSConstant;
import com.baosight.hpjx.util.FileUtils;
import com.baosight.hpjx.util.MapUtils;
import com.baosight.hpjx.util.StringUtils;
import com.baosight.iplat4j.core.ioc.spring.PlatApplicationContext;
import com.baosight.iplat4j.core.util.DateUtils;
import com.baosight.iplat4j.core.web.threadlocal.UserSession;
import com.baosight.iplat4j.eu.dm.PlatFileUploadUtils;
import com.baosight.iplat4j.eu.dm.util.IFileUploader;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
/**
* 二维码工具类
*
* @author:songx
* @date:2024/4/16,14:47
*/
@Slf4j
public class QrCodeUtils {
// CODE_WIDTH:二维码宽度,单位像素
private static final int CODE_WIDTH = 400;
// CODE_HEIGHT:二维码高度,单位像素
private static final int CODE_HEIGHT = 400;
// FRONT_COLOR:二维码前景色,0x000000 表示黑色
private static final int FRONT_COLOR = 0x000000;
// BACKGROUND_COLOR:二维码背景色,0xFFFFFF 表示白色
// 演示用 16 进制表示,和前端页面 CSS 的取色是一样的,注意前后景颜色应该对比明显,如常见的黑白
private static final int BACKGROUND_COLOR = 0xFFFFFF;
/**
* 生成本地文件
* {
* "file": "D:\\home\\appuser\\qrCode\\20240416162700_mizw6izh.png",
* "docId": "90f1a41a48e644d1a56682be03a231db",
* "filePath": "D:\\home\\appuser\\qrCode\\20240416162700_mizw6izh.png",
* "fileLocation": "local"
* }
*
* @param content
*/
public static Map<String, Object> create(String content) throws Exception {
String fileLocation = PlatApplicationContext.getProperty("iplat4j.admin.upload.fileLocation");
if ("S3".equals(fileLocation)) {
return createByS3(content);
} else {
return createByLocal(content);
}
}
/**
* 生成二维码到S3
*
* @param content
* @return
*/
private static Map<String, Object> createByS3(String content) throws Exception {
// 生成二维码
File file = createFile(null, content);
Map inMap = new HashMap();
inMap.put("groupId", "hk_file");
inMap.put("configPathDefine", "qrCode");
Map<String, String> uploadMap = PlatFileUploadUtils.uploadFile(file, inMap);
log.warn("uploadMap", uploadMap);
String docId = MapUtils.getString(uploadMap, "docId");
// 上传成功以后需要删除本地文件
file.delete();
Map resultMap = new HashMap();
resultMap.put("fileLocation", "S3");
resultMap.put("docId", docId);
resultMap.put("filePath", MapUtils.getString(uploadMap, "docUrl"));
return resultMap;
}
/**
* 生成本地文件
*
* @param content
* @return
*/
private static Map<String, Object> createByLocal(String content) throws Exception {
IFileUploader fileUploader = PlatApplicationContext.getApplicationContext()
.getBean("platFileUploader", IFileUploader.class);
Map<String, String> pathMap = fileUploader.getRealPath("qrCode");
String category = pathMap.get("path");
File dir = new File(category);
if (!dir.exists()) {
dir.mkdirs();
}
String fileName = StringUtils.uuid();
String fileNameAll = fileName + ".png";
String chgName = fileUploader.transformFileName(fileNameAll);
// 生成本地文件
File file = createFile(category + "/" + chgName, content);
// 写入记录
Map map = new HashMap();
map.put("docId", fileName);
map.put("dirId", pathMap.get("dirId"));
map.put("docTag", "hk_file");
map.put("docName", fileNameAll);
map.put("chgName", chgName);
map.put("docSize", file.length());
map.put("recCreator", UserSession.getLoginName());
map.put("recCreateTime", DateUtils.curDateTimeStr14());
fileUploader.uploadDoc(map);
Map resultMap = new HashMap();
resultMap.put("fileLocation", "local");
resultMap.put("docId", fileName);
resultMap.put("filePath", file.getAbsolutePath());
resultMap.put("file", file);
return resultMap;
}
/**
* 生成二维码文件
*
* @param filePath
* @param content
* @return
* @throws Exception
*/
private static File createFile(String filePath, String content) throws IOException, WriterException {
// 文件如果不存在就创建
if (StringUtils.isBlank(filePath)) {
filePath = OSConstant.QRCODE_DIR + OSConstant.SEPARATOR + StringUtils.uuid() + ".png";
}
FileUtils.creatFiles(filePath);
File file = new File(filePath);
//核心代码-生成二维码
BufferedImage bufferedImage = getBufferedImage(content.trim());
ImageIO.write(bufferedImage, "png", file);
return file;
}
/**
* 生成二维码并输出到输出流, 通常用于输出到网页上进行显示,输出到网页与输出到磁盘上的文件中,区别在于最后一句 ImageIO.write
* write(RenderedImage im,String formatName,File output):写到文件中
* write(RenderedImage im,String formatName,OutputStream output):输出到输出流中
*
* @param content :二维码内容
* @param outputStream :输出流,比如 HttpServletResponse 的 getOutputStream
*/
public static void create(String content, OutputStream outputStream) throws WriterException, IOException {
if (StringUtils.isBlank(content)) {
return;
}
content = content.trim();
//核心代码-生成二维码
BufferedImage bufferedImage = getBufferedImage(content);
//区别就是这一句,输出到输出流中,如果第三个参数是 File,则输出到文件中
ImageIO.write(bufferedImage, "png", outputStream);
}
/**
* 核心代码-生成二维码
*
* @param content
* @return
* @throws WriterException
*/
private static BufferedImage getBufferedImage(String content) throws WriterException {
//com.google.zxing.EncodeHintType:编码提示类型,枚举类型
Map<EncodeHintType, Object> hints = new HashMap();
//EncodeHintType.CHARACTER_SET:设置字符编码类型
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
//EncodeHintType.ERROR_CORRECTION:设置误差校正
//ErrorCorrectionLevel:误差校正等级,L = ~7% correction、M = ~15% correction、Q = ~25% correction、H = ~30% correction
//不设置时,默认为 L 等级,等级不一样,生成的图案不同,但扫描的结果是一样的
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);
//EncodeHintType.MARGIN:设置二维码边距,单位像素,值越小,二维码距离四周越近
hints.put(EncodeHintType.MARGIN, 1);
MultiFormatWriter multiFormatWriter = new MultiFormatWriter();
BitMatrix bitMatrix = multiFormatWriter.encode(content, BarcodeFormat.QR_CODE, CODE_WIDTH, CODE_HEIGHT, hints);
BufferedImage bufferedImage = new BufferedImage(CODE_WIDTH, CODE_HEIGHT, BufferedImage.TYPE_INT_BGR);
for (int x = 0; x < CODE_WIDTH; x++) {
for (int y = 0; y < CODE_HEIGHT; y++) {
bufferedImage.setRGB(x, y, bitMatrix.get(x, y) ? FRONT_COLOR : BACKGROUND_COLOR);
}
}
return bufferedImage;
}
}
...@@ -316,6 +316,8 @@ public class HPSqlConstant { ...@@ -316,6 +316,8 @@ public class HPSqlConstant {
// 修改状态 // 修改状态
public static final String UPDATE_STATUS = "HPSC003.updateStatus"; public static final String UPDATE_STATUS = "HPSC003.updateStatus";
// 修改状态
public static final String UPDATE_QRCODE = "HPSC003.updateQrcode";
// 修改时间 // 修改时间
public static final String UPDATE_DATE = "HPSC003.updateDate"; public static final String UPDATE_DATE = "HPSC003.updateDate";
......
...@@ -43,9 +43,9 @@ public class HPSC003 extends DaoEPBase { ...@@ -43,9 +43,9 @@ public class HPSC003 extends DaoEPBase {
public static final String FIELD_SCHEDULE = "schedule"; public static final String FIELD_SCHEDULE = "schedule";
public static final String FIELD_DELIVERY_DATE = "deliveryDate"; public static final String FIELD_DELIVERY_DATE = "deliveryDate";
public static final String FIELD_INVENT_RECORD_ID = "inventRecordId"; public static final String FIELD_INVENT_RECORD_ID = "inventRecordId";
public static final String FIELD_QRCODE_DOC_ID = "qrcodeDocId";
public static final String FIELD_FACTORY_CODE = "factoryCode"; public static final String FIELD_FACTORY_CODE = "factoryCode";
public static final String COL_ID = "ID"; public static final String COL_ID = "ID";
public static final String COL_COMPANY_CODE = "COMPANY_CODE"; /* 企业编码 预留*/ public static final String COL_COMPANY_CODE = "COMPANY_CODE"; /* 企业编码 预留*/
public static final String COL_PROJ_TYPE = "PROJ_TYPE"; /* 项目类型*/ public static final String COL_PROJ_TYPE = "PROJ_TYPE"; /* 项目类型*/
...@@ -65,6 +65,7 @@ public class HPSC003 extends DaoEPBase { ...@@ -65,6 +65,7 @@ public class HPSC003 extends DaoEPBase {
public static final String COL_REMARK = "REMARK"; /* 备注*/ public static final String COL_REMARK = "REMARK"; /* 备注*/
public static final String COL_INVENT_RECORD_ID = "INVENT_RECORD_ID"; public static final String COL_INVENT_RECORD_ID = "INVENT_RECORD_ID";
public static final String COL_DELIVERY_DATE = "DELIVERY_DATE"; public static final String COL_DELIVERY_DATE = "DELIVERY_DATE";
public static final String COL_QRCODE_DOC_ID = "QRCODE_DOC_ID";
public static final String COL_FACTORY_CODE = "FACTORY_CODE"; /* 工厂代码*/ public static final String COL_FACTORY_CODE = "FACTORY_CODE"; /* 工厂代码*/
public static final String QUERY = "HPSC003.query"; public static final String QUERY = "HPSC003.query";
...@@ -91,17 +92,14 @@ public class HPSC003 extends DaoEPBase { ...@@ -91,17 +92,14 @@ public class HPSC003 extends DaoEPBase {
private String depCode = " "; /* 部门编码*/ private String depCode = " "; /* 部门编码*/
private String remark = " "; /* 备注*/ private String remark = " "; /* 备注*/
private Long matId = null; /* 物料ID*/ private Long matId = null; /* 物料ID*/
private String schedule = ""; private String schedule = "";
private String deliveryDate = " "; private String deliveryDate = " ";
private Long inventRecordId = new Long(0); private Long inventRecordId = new Long(0);
private String spec = " "; /* 规格*/ private String spec = " "; /* 规格*/
private BigDecimal length = new BigDecimal(0.00); /* 长*/ private BigDecimal length = new BigDecimal(0.00); /* 长*/
private BigDecimal width = new BigDecimal(0.00); /* 宽*/ private BigDecimal width = new BigDecimal(0.00); /* 宽*/
private BigDecimal thick = new BigDecimal(0.00); /* 厚*/ private BigDecimal thick = new BigDecimal(0.00); /* 厚*/
private String qrcodeDocId = " "; /* 二维码文件ID */
private String factoryCode = " "; /* 工厂代码*/ private String factoryCode = " "; /* 工厂代码*/
...@@ -221,6 +219,10 @@ public class HPSC003 extends DaoEPBase { ...@@ -221,6 +219,10 @@ public class HPSC003 extends DaoEPBase {
eiColumn.setDescName("交货日期"); eiColumn.setDescName("交货日期");
eiMetadata.addMeta(eiColumn); eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_QRCODE_DOC_ID);
eiColumn.setDescName("二维码文件ID");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_FACTORY_CODE); eiColumn = new EiColumn(FIELD_FACTORY_CODE);
eiColumn.setDescName("工厂代码"); eiColumn.setDescName("工厂代码");
eiMetadata.addMeta(eiColumn); eiMetadata.addMeta(eiColumn);
...@@ -595,6 +597,15 @@ public class HPSC003 extends DaoEPBase { ...@@ -595,6 +597,15 @@ public class HPSC003 extends DaoEPBase {
this.deliveryDate = deliveryDate; this.deliveryDate = deliveryDate;
} }
public String getQrcodeDocId() {
return qrcodeDocId;
}
public void setQrcodeDocId(String qrcodeDocId) {
this.qrcodeDocId = qrcodeDocId;
}
public String getFactoryCode() { public String getFactoryCode() {
return factoryCode; return factoryCode;
} }
...@@ -636,6 +647,7 @@ public class HPSC003 extends DaoEPBase { ...@@ -636,6 +647,7 @@ public class HPSC003 extends DaoEPBase {
setThick(NumberUtils.toBigDecimal(StringUtils.toString(map.get("thick")), thick)); setThick(NumberUtils.toBigDecimal(StringUtils.toString(map.get("thick")), thick));
setMatId(NumberUtils.toLong(StringUtils.toString(map.get("matId")), matId)); setMatId(NumberUtils.toLong(StringUtils.toString(map.get("matId")), matId));
setDeliveryDate(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_DELIVERY_DATE)), deliveryDate)); setDeliveryDate(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_DELIVERY_DATE)), deliveryDate));
setQrcodeDocId(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_QRCODE_DOC_ID)), qrcodeDocId));
setFactoryCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_FACTORY_CODE)), factoryCode)); setFactoryCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_FACTORY_CODE)), factoryCode));
} }
...@@ -671,6 +683,7 @@ public class HPSC003 extends DaoEPBase { ...@@ -671,6 +683,7 @@ public class HPSC003 extends DaoEPBase {
map.put("thick", StringUtils.toString(thick, eiMetadata.getMeta("thick"))); map.put("thick", StringUtils.toString(thick, eiMetadata.getMeta("thick")));
map.put("matId", StringUtils.toString(matId, eiMetadata.getMeta("matId"))); map.put("matId", StringUtils.toString(matId, eiMetadata.getMeta("matId")));
map.put(FIELD_DELIVERY_DATE, StringUtils.toString(deliveryDate, eiMetadata.getMeta(FIELD_DELIVERY_DATE))); map.put(FIELD_DELIVERY_DATE, StringUtils.toString(deliveryDate, eiMetadata.getMeta(FIELD_DELIVERY_DATE)));
map.put(FIELD_QRCODE_DOC_ID, StringUtils.toString(qrcodeDocId, eiMetadata.getMeta(FIELD_QRCODE_DOC_ID)));
map.put(FIELD_FACTORY_CODE, StringUtils.toString(factoryCode, eiMetadata.getMeta(FIELD_FACTORY_CODE))); map.put(FIELD_FACTORY_CODE, StringUtils.toString(factoryCode, eiMetadata.getMeta(FIELD_FACTORY_CODE)));
return map; return map;
......
...@@ -10,12 +10,16 @@ import com.baosight.hpjx.hp.constant.HPSqlConstant; ...@@ -10,12 +10,16 @@ import com.baosight.hpjx.hp.constant.HPSqlConstant;
import com.baosight.hpjx.hp.sc.domain.HPSC003; import com.baosight.hpjx.hp.sc.domain.HPSC003;
import com.baosight.hpjx.hp.sc.domain.HPSC004; import com.baosight.hpjx.hp.sc.domain.HPSC004;
import com.baosight.hpjx.hp.sc.domain.HPSC005; import com.baosight.hpjx.hp.sc.domain.HPSC005;
import com.baosight.hpjx.hp.sc.domain.HPSC005B;
import com.baosight.hpjx.hp.sc.tools.HPSCTools; import com.baosight.hpjx.hp.sc.tools.HPSCTools;
import com.baosight.hpjx.util.AssertUtils;
import com.baosight.hpjx.util.BeanUtils; import com.baosight.hpjx.util.BeanUtils;
import com.baosight.hpjx.util.CommonMethod; import com.baosight.hpjx.util.CommonMethod;
import com.baosight.hpjx.util.DateUtils; import com.baosight.hpjx.util.DateUtils;
import com.baosight.hpjx.util.EiInfoUtils; import com.baosight.hpjx.util.EiInfoUtils;
import com.baosight.hpjx.util.LogUtils; import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.MapUtils;
import com.baosight.hpjx.util.ObjectUtils;
import com.baosight.hpjx.util.StringUtils; import com.baosight.hpjx.util.StringUtils;
import com.baosight.hpjx.util.contants.ACConstants; import com.baosight.hpjx.util.contants.ACConstants;
import com.baosight.iplat4j.core.ei.EiBlock; import com.baosight.iplat4j.core.ei.EiBlock;
...@@ -23,12 +27,9 @@ import com.baosight.iplat4j.core.ei.EiConstant; ...@@ -23,12 +27,9 @@ import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo; import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException; import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.impl.ServiceBase; import com.baosight.iplat4j.core.service.impl.ServiceBase;
import com.baosight.iplat4j.core.service.soa.XLocalManager;
import com.baosight.iplat4j.core.web.threadlocal.UserSession; import com.baosight.iplat4j.core.web.threadlocal.UserSession;
import com.baosight.iplat4j.ed.util.SequenceGenerator; import com.baosight.iplat4j.ed.util.SequenceGenerator;
import org.apache.commons.collections.MapUtils;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
...@@ -36,7 +37,6 @@ import java.util.Date; ...@@ -36,7 +37,6 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random;
/** /**
* *
...@@ -222,6 +222,10 @@ public class ServiceHPSC003 extends ServiceBase { ...@@ -222,6 +222,10 @@ public class ServiceHPSC003 extends ServiceBase {
} }
// 修改计划状态 // 修改计划状态
HPSCTools.HpSc003.updateStatus(id, HPConstant.planStatus.S_1); HPSCTools.HpSc003.updateStatus(id, HPConstant.planStatus.S_1);
// 生成二维码
if (StringUtils.isBlank(dbSc003.getQrcodeDocId())) {
HPSCTools.HpSc003.createQrCode(id);
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT); inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("提交成功"); inInfo.setMsg("提交成功");
} catch (Exception e) { } catch (Exception e) {
...@@ -274,7 +278,7 @@ public class ServiceHPSC003 extends ServiceBase { ...@@ -274,7 +278,7 @@ public class ServiceHPSC003 extends ServiceBase {
* @param inInfo * @param inInfo
* @return * @return
*/ */
@OperationLogAnnotation(operModul = "生产计划",operType = "查询",operDesc = "部件下拉框") @OperationLogAnnotation(operModul = "生产计划", operType = "查询", operDesc = "部件下拉框")
public EiInfo queryInventComboBox(EiInfo inInfo) { public EiInfo queryInventComboBox(EiInfo inInfo) {
List<DdynamicEnum> list = new ArrayList<>(); List<DdynamicEnum> list = new ArrayList<>();
list.add(DdynamicEnum.INVENT_RECORD_BLOCK_ID); list.add(DdynamicEnum.INVENT_RECORD_BLOCK_ID);
...@@ -282,4 +286,34 @@ public class ServiceHPSC003 extends ServiceBase { ...@@ -282,4 +286,34 @@ public class ServiceHPSC003 extends ServiceBase {
return inInfo; return inInfo;
} }
/**
* 扫码显示计划明细
*
* @param inInfo
* @return
*/
public EiInfo qrcodePlanDetail(EiInfo inInfo) {
try {
Map queryRow = EiInfoUtils.getFirstRow(inInfo);
String planInfoNo = MapUtils.getString(queryRow, HPSC003.FIELD_PLAN_INFO_NO);
AssertUtils.isNull(planInfoNo, "计划号不能为空");
// 查询计划主信息
HPSC003 dbSc003 = HPSCTools.HpSc003.getByNo(planInfoNo);
EiInfoUtils.addBlock(inInfo, "planMain", dbSc003, HPSC003.class);
// 查询计划明细信息
List<HPSC004> dbSc004s = HPSCTools.HpSc004.queryByParent(dbSc003.getPlanInfoNo());
EiInfoUtils.addBlock(inInfo, "planDetail", dbSc004s, HPSC004.class);
// 订单号
List<String> prodOrderNos = ObjectUtils.listEpKey(dbSc004s, HPSC004.FIELD_PROD_ORDER_NO);
// 查询派工信息
List<HPSC005B> dbSc005bs = HPSCTools.HpSc005b.listByOrder(prodOrderNos);
EiInfoUtils.addBlock(inInfo, "prodOrder", dbSc005bs, HPSC005B.class);
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "查询计划详情失败");
// 小程序端要求,错误码使用500
inInfo.setStatus(500);
}
return inInfo;
}
} }
...@@ -108,6 +108,7 @@ ...@@ -108,6 +108,7 @@
THICK as "thick", <!-- 厚 --> THICK as "thick", <!-- 厚 -->
MAT_ID AS "matId", MAT_ID AS "matId",
DELIVERY_DATE as "deliveryDate", DELIVERY_DATE as "deliveryDate",
QRCODE_DOC_ID as "qrcodeDocId",
FACTORY_CODE as "factoryCode", <!-- 工厂代码 --> FACTORY_CODE as "factoryCode", <!-- 工厂代码 -->
CONCAT(( CONCAT((
SELECT SELECT
...@@ -240,4 +241,13 @@ ...@@ -240,4 +241,13 @@
WHERE ID = #id# WHERE ID = #id#
</update> </update>
<!-- 修改二维码地址 -->
<update id="updateQrcode">
UPDATE hpjx.T_HPSC003
SET
QRCODE_DOC_ID = #qrcodeDocId#,
<include refid="updateRevise"/>
WHERE ID = #id#
</update>
</sqlMap> </sqlMap>
...@@ -108,6 +108,9 @@ ...@@ -108,6 +108,9 @@
<isNotEmpty prepend=" AND " property="ids"> <isNotEmpty prepend=" AND " property="ids">
A.ID IN <iterate close=")" open="(" conjunction="," property="statuses">#statuses[]#</iterate> A.ID IN <iterate close=")" open="(" conjunction="," property="statuses">#statuses[]#</iterate>
</isNotEmpty> </isNotEmpty>
<isNotEmpty prepend=" AND " property="prodOrderNos">
A.PROD_ORDER_NO IN <iterate close=")" open="(" conjunction="," property="prodOrderNos">#prodOrderNos[]#</iterate>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="prodTaskNos"> <isNotEmpty prepend=" AND " property="prodTaskNos">
B.PROD_TASK_NO IN <iterate close=")" open="(" conjunction="," property="prodTaskNos">#prodTaskNos[]#</iterate> B.PROD_TASK_NO IN <iterate close=")" open="(" conjunction="," property="prodTaskNos">#prodTaskNos[]#</iterate>
</isNotEmpty> </isNotEmpty>
...@@ -128,7 +131,7 @@ ...@@ -128,7 +131,7 @@
$order$ $order$
</isNotEmpty> </isNotEmpty>
<isEmpty property="order"> <isEmpty property="order">
A.CREATED_TIME desc A.PROD_ORDER_NO DESC, B.PROD_TASK_NO ASC
</isEmpty> </isEmpty>
</dynamic> </dynamic>
</sql> </sql>
......
...@@ -3,6 +3,7 @@ package com.baosight.hpjx.hp.sc.tools; ...@@ -3,6 +3,7 @@ package com.baosight.hpjx.hp.sc.tools;
import com.baosight.hpjx.core.dao.DaoBase; import com.baosight.hpjx.core.dao.DaoBase;
import com.baosight.hpjx.core.dao.DaoUtils; import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.core.security.UserSessionUtils; import com.baosight.hpjx.core.security.UserSessionUtils;
import com.baosight.hpjx.core.utils.QrCodeUtils;
import com.baosight.hpjx.hp.constant.HPSqlConstant; import com.baosight.hpjx.hp.constant.HPSqlConstant;
import com.baosight.hpjx.hp.sc.domain.HPSC001; import com.baosight.hpjx.hp.sc.domain.HPSC001;
import com.baosight.hpjx.hp.sc.domain.HPSC002; import com.baosight.hpjx.hp.sc.domain.HPSC002;
...@@ -17,11 +18,11 @@ import com.baosight.hpjx.hp.sc.domain.HPSC007; ...@@ -17,11 +18,11 @@ import com.baosight.hpjx.hp.sc.domain.HPSC007;
import com.baosight.hpjx.util.AssertUtils; import com.baosight.hpjx.util.AssertUtils;
import com.baosight.hpjx.util.DateUtils; import com.baosight.hpjx.util.DateUtils;
import com.baosight.hpjx.util.StringUtils; import com.baosight.hpjx.util.StringUtils;
import com.baosight.iplat4j.core.ioc.spring.PlatApplicationContext;
import com.baosight.iplat4j.core.util.NumberUtils; import com.baosight.iplat4j.core.util.NumberUtils;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -406,6 +407,7 @@ public class HPSCTools { ...@@ -406,6 +407,7 @@ public class HPSCTools {
queryMap.put("matId", matId); queryMap.put("matId", matId);
DaoBase.getInstance().update(HPSqlConstant.HPSC003.DELETE_BY_MAT, queryMap); DaoBase.getInstance().update(HPSqlConstant.HPSC003.DELETE_BY_MAT, queryMap);
} }
/** /**
* 修改状态 * 修改状态
* *
...@@ -421,6 +423,25 @@ public class HPSCTools { ...@@ -421,6 +423,25 @@ public class HPSCTools {
} }
/** /**
* 生成二维码
*
* @param id
*/
public static void createQrCode(Long id) throws Exception {
AssertUtils.isNull(id, "节点ID不能为空");
// 取配置地址
String url = PlatApplicationContext.getProperty("iplat.planInfo.qrcode.url");
if (StringUtils.isBlank(url)) {
return;
}
Map<String, Object> resultMap = QrCodeUtils.create(String.format(url, id));
Map map = new HashMap();
map.put("id", id);
map.put("qrcodeDocId", resultMap.get("docId"));
DaoUtils.update(HPSqlConstant.HPSC003.UPDATE_QRCODE, map);
}
/**
* 修改计划完成时间 * 修改计划完成时间
* *
* @param planInfoNo * @param planInfoNo
...@@ -440,12 +461,12 @@ public class HPSCTools { ...@@ -440,12 +461,12 @@ public class HPSCTools {
* @param planInfoNo * @param planInfoNo
* @return * @return
*/ */
public static HPSC003 getEntityByPlanInfoNo(String planInfoNo) { public static HPSC003 getByNo(String planInfoNo) {
AssertUtils.isNull(planInfoNo, "生产订单号不能为空"); AssertUtils.isNull(planInfoNo, "计划号不能为空");
Map queryMap = new HashMap(); Map queryMap = new HashMap();
queryMap.put("planInfoNo", planInfoNo); queryMap.put("planInfoNo", planInfoNo);
List<HPSC003> results = DaoBase.getInstance().query(HPSC003.QUERY, queryMap); List<HPSC003> results = DaoBase.getInstance().query(HPSC003.QUERY, queryMap);
AssertUtils.isNull(results, String.format("生产订单号[%s]信息不存在", planInfoNo)); AssertUtils.isNull(results, String.format("计划号[%s]信息不存在", planInfoNo));
return results.get(0); return results.get(0);
} }
} }
...@@ -872,6 +893,21 @@ public class HPSCTools { ...@@ -872,6 +893,21 @@ public class HPSCTools {
} }
/** /**
* 查询盘点单信息
*
* @param prodOrderNos
* @return
*/
public static List<HPSC005B> listByOrder(List<String> prodOrderNos) {
if (CollectionUtils.isEmpty(prodOrderNos)) {
return null;
}
Map queryMap = new HashMap();
queryMap.put("prodOrderNos", prodOrderNos);
return DaoBase.getInstance().query(HPSC005B.QUERY, queryMap);
}
/**
* 查询信息 * 查询信息
* *
* @param factoryCode * @param factoryCode
......
package com.baosight.hpjx.util; package com.baosight.hpjx.util;
import com.baosight.iplat4j.core.BaseObject; import com.baosight.iplat4j.core.BaseObject;
import com.baosight.iplat4j.core.data.DaoEPBase;
import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiConstant; import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo; import com.baosight.iplat4j.core.ei.EiInfo;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -107,4 +110,42 @@ public class EiInfoUtils { ...@@ -107,4 +110,42 @@ public class EiInfoUtils {
rowMap.put(key, value); rowMap.put(key, value);
} }
/**
* eiinfo中新增block
*
* @param inInfo
* @param blockId
* @param row
* @param clazz
* @param <T>
* @throws InstantiationException
* @throws IllegalAccessException
*/
public static <T extends DaoEPBase> void addBlock(EiInfo inInfo, String blockId, T row, Class<T> clazz)
throws InstantiationException, IllegalAccessException {
EiBlock block = new EiBlock(blockId);
block.addBlockMeta(clazz.newInstance().eiMetadata);
block.addRow(row);
inInfo.setBlock(block);
}
/**
* eiinfo中新增block
*
* @param inInfo
* @param blockId
* @param rows
* @param clazz
* @param <T>
* @throws InstantiationException
* @throws IllegalAccessException
*/
public static <T extends DaoEPBase> void addBlock(EiInfo inInfo, String blockId, List<T> rows, Class<T> clazz)
throws InstantiationException, IllegalAccessException {
EiBlock block = new EiBlock(blockId);
block.addBlockMeta(clazz.newInstance().eiMetadata);
block.addRows(rows);
inInfo.setBlock(block);
}
} }
...@@ -65,6 +65,7 @@ public class LogUtils { ...@@ -65,6 +65,7 @@ public class LogUtils {
* @return * @return
*/ */
public static String getMsg(Throwable e) { public static String getMsg(Throwable e) {
logger.error("转换系统异常:{}", e.getMessage(), e);
if (e instanceof PlatException) { if (e instanceof PlatException) {
return e.getMessage(); return e.getMessage();
} else { } else {
......
package com.baosight.hpjx.util; package com.baosight.hpjx.util;
import com.baosight.iplat4j.core.data.DaoEPBase;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -119,4 +121,19 @@ public class ObjectUtils extends org.apache.commons.lang.ObjectUtils { ...@@ -119,4 +121,19 @@ public class ObjectUtils extends org.apache.commons.lang.ObjectUtils {
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
/**
* 从DaoEPBase中取KEY
*
* @param items
* @param keyName
* @return
*/
public static <T> List<T> listEpKey(Collection<? extends DaoEPBase> items, String keyName) {
if (CollectionUtils.isEmpty(items)) {
return null;
}
return items.stream().map(item -> item.toMap()).map(item -> (T) item.get(keyName))
.filter(ObjectUtils::isNotBlank).distinct().collect(Collectors.toList());
}
} }
...@@ -19,7 +19,7 @@ spring.servlet.multipart.file-size-threshold =0 ...@@ -19,7 +19,7 @@ spring.servlet.multipart.file-size-threshold =0
componentEname=hpjx componentEname=hpjx
projectName=hpjx projectName=hpjx
moduleName=ep moduleName=ep
projectEnv=run projectEnv=dev
platSchema=iplat platSchema=iplat
eplatSchema=EPLAT eplatSchema=EPLAT
lowcodedbSchema=lowcodedb lowcodedbSchema=lowcodedb
...@@ -33,11 +33,12 @@ customerName=\u6B66\u6C49\u5B9D\u4FE1\u5927\u6570\u636E\u4E8B\u4E1A\u90E8 ...@@ -33,11 +33,12 @@ customerName=\u6B66\u6C49\u5B9D\u4FE1\u5927\u6570\u636E\u4E8B\u4E1A\u90E8
enterpriseName=\u6B66\u6C49\u5B9D\u4FE1\u5927\u6570\u636E\u4E8B\u4E1A\u90E8 enterpriseName=\u6B66\u6C49\u5B9D\u4FE1\u5927\u6570\u636E\u4E8B\u4E1A\u90E8
datasource.type=dbcp datasource.type=dbcp
jdbc.driverClassName=com.mysql.jdbc.Driver jdbc.driverClassName=com.mysql.jdbc.Driver
#jdbc.url=jdbc:mysql://127.0.0.1:3306/iplat?useSSL=false&useUnicode=true&characterEncoding=utf-8 jdbc.url=jdbc:mysql://127.0.0.1:3306/iplat?useSSL=false&useUnicode=true&characterEncoding=utf-8
jdbc.url=jdbc:mysql://10.135.13.5:30005/iplat?useSSL=false&useUnicode=true&characterEncoding=utf-8 #jdbc.url=jdbc:mysql://10.135.13.5:30005/iplat?useSSL=false&useUnicode=true&characterEncoding=utf-8
jdbc.username=dbprod32 #jdbc.username=dbprod32
jdbc.password=t9UrgcELp= jdbc.username=root
#jdbc.password=123456 #jdbc.password=t9UrgcELp=
jdbc.password=123456
jdbc.maxActive=20 jdbc.maxActive=20
jdbc.validationQuery=SELECT 1 FROM ${platSchema}.TEDFA00 jdbc.validationQuery=SELECT 1 FROM ${platSchema}.TEDFA00
......
...@@ -26,12 +26,12 @@ org.quartz.jobStore.isClustered = true ...@@ -26,12 +26,12 @@ org.quartz.jobStore.isClustered = true
#\uFFFD\u02F4\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u077F\uFFFD\u05BE\u00FB\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u077F\uFFFD\uFFFD\uFFFD\u0635\uFFFD\uFFFD\uFFFD\u03E2 #\uFFFD\u02F4\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u077F\uFFFD\u05BE\u00FB\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u077F\uFFFD\uFFFD\uFFFD\u0635\uFFFD\uFFFD\uFFFD\u03E2
org.quartz.jobStore.clusterCheckinInterval = 20000 org.quartz.jobStore.clusterCheckinInterval = 20000
org.quartz.dataSource.appDS.driver = com.mysql.jdbc.Driver org.quartz.dataSource.appDS.driver = com.mysql.jdbc.Driver
org.quartz.dataSource.appDS.URL = jdbc:mysql://10.135.13.5:30005/iplat?useSSL=false&useUnicode=true&characterEncoding=utf-8 #org.quartz.dataSource.appDS.URL = jdbc:mysql://10.135.13.5:30005/iplat?useSSL=false&useUnicode=true&characterEncoding=utf-8
#org.quartz.dataSource.appDS.URL = jdbc:mysql://127.0.0.1:3306/iplat?useSSL=false&useUnicode=true&characterEncoding=utf-8 org.quartz.dataSource.appDS.URL = jdbc:mysql://127.0.0.1:3306/iplat?useSSL=false&useUnicode=true&characterEncoding=utf-8
#org.quartz.dataSource.appDS.user = dbprod32
org.quartz.dataSource.appDS.user = dbprod32 org.quartz.dataSource.appDS.user = root
#org.quartz.dataSource.appDS.password =root #org.quartz.dataSource.appDS.password =t9UrgcELp=
org.quartz.dataSource.appDS.password =t9UrgcELp= org.quartz.dataSource.appDS.password =123456
org.quartz.dataSource.appDS.maxConnections = 30 org.quartz.dataSource.appDS.maxConnections = 30
#\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u05B1\uFFFD\uFFFD\uFFFD\uFFFD\u05BE\uFFFD\uFFFD\u00BC\uFFFD\uFFFD\uFFFD #\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u05B1\uFFFD\uFFFD\uFFFD\uFFFD\u05BE\uFFFD\uFFFD\u00BC\uFFFD\uFFFD\uFFFD
......
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