Commit ced5cf4c by liulei

移动端接口优化

parent 097491c0
......@@ -127,6 +127,19 @@ public enum DdynamicEnum {
*/
FACTORY_GROUP_ECORD_BLOCK_ID("factory_group_ecord_block_id","factoryCode","factoryName","groupCode","groupName","HPPZ011.queryComboBoxAll"),
/**
* 模块:组管理
* 用途:组管理下拉框
* 编写:ll
*/
GROUP_PRO_BLOCK_ID("group_pro_block_id","groupCode","groupName","HPXSOrg.queryList"),
/**
* 模块:巡检移动端
* 用途:不良品类下拉
* 编写:ll
*/
POOR_TYPE_BLOCK_ID("poor_type_block_id","itemCode","itemCname","HPXSOrg.queryTedcm01"),
//------------------------------------生产管理-----------------------------------
/**
* 模块:项目档案
......@@ -164,8 +177,21 @@ public enum DdynamicEnum {
* 编写:wwl
*/
PROJ_PROD_BLOCK_ID("proj_prod_block_id","projCode","projName","HPSC005.queryProjComboBox"),
/**
* 模块:项目档案(通过工厂、生产组)
* 用途:项目档案下拉框
* 编写:ll
*/
PROJ_PRODQUERY_BLOCK_ID("proj_prodQuery_block_id","projCode","projName","HPSC005.queryProjComboBox2"),
/**
* 模块:项目档案(通过工厂、生产组、项目号)
* 用途:移动端任务号、生产订单号
* 编写:ll
*/
PROJ_QUERYPROD_BLOCK_ID("proj_queryProd_block_id","prodOrderNo","prodTaskNo","HPSC005.queryProjComboBox2"),
//------------------------------------用户管理-----------------------------------
/**
......@@ -225,6 +251,9 @@ public enum DdynamicEnum {
*/
FACTORY_CODE_BLOCK_ID("factory_code_block_id","factoryCode","factoryName","HPXS001.queryFactoryCode");
/** 将结果集放入的块名 */
private final String blockId;
/** 字段名 */
......
package com.baosight.hpjx.hp.mt.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.servlet.multipart.UploadFile;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.core.security.UserSessionUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.constant.HPSqlConstant;
import com.baosight.hpjx.hp.mt.untils.uploadUntil;
import com.baosight.hpjx.hp.pz.domain.HPPZ011;
import com.baosight.hpjx.hp.mt.untils.Base64ToMultipartFile;
import com.baosight.hpjx.hp.mt.untils.Base64Utils;
import com.baosight.hpjx.hp.mt.untils.UploadUtils;
import com.baosight.hpjx.hp.sc.domain.HPSC002A;
import com.baosight.hpjx.hp.sc.domain.HPSC005;
import com.baosight.hpjx.hp.xs.domain.User;
import com.baosight.hpjx.hp.zl.domain.HPZL001;
import com.baosight.hpjx.hp.zl.domain.HPZL001A;
import com.baosight.hpjx.util.*;
import com.baosight.iplat4j.config.AdminFactoryConfig;
import com.baosight.iplat4j.common.ed.domain.TEDCM01;
import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import net.sf.json.JSONObject;
import org.apache.commons.collections.MapUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* 鸿鹏机械APP移动端接口调用处
*/
......@@ -95,8 +108,7 @@ public class ServiceHPMT002 extends ServiceBase {
* @return
*/
public EiInfo pmQualityList(EiInfo inInfo) {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String status = MapUtils.getString(queryMap, "status");
String status = inInfo.getString("status");
String companyCode = UserSessionUtils.getCompanyCode();
if (StrUtil.isEmpty(companyCode)) {
inInfo.setMsg("账号异常");
......@@ -120,22 +132,40 @@ public class ServiceHPMT002 extends ServiceBase {
* @return
*/
public EiInfo pmQualityDetail(EiInfo inInfo) {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String status = MapUtils.getString(queryMap, "status");
String checkNo = MapUtils.getString(queryMap, "checkNo");
String companyCode = UserSessionUtils.getCompanyCode();
if (StrUtil.isEmpty(companyCode)) {
inInfo.setMsg("账号异常");
}
Map sqlMap = new HashMap();
sqlMap.put("companyCode", companyCode);
sqlMap.put("status", status);
sqlMap.put("checkNo", checkNo);
List<Map> rows = this.dao.query("HPMT002.pmQualityDetail", sqlMap);
EiInfo outInfo = new EiInfo();
EiBlock eiBlock = new EiBlock(EiConstant.resultBlock);
eiBlock.setRows(rows);
outInfo.setBlock(eiBlock);
try {
String id = inInfo.getString("id");
String companyCode = UserSessionUtils.getCompanyCode();
if (StrUtil.isEmpty(companyCode)) {
outInfo.setMsg("账号异常");
}
Map Map = new HashMap();
Map.put("checkId", id);
Map.put("docType", "XJ_WC");
List<HPZL001A> docIdlist = this.dao.query("HPZL001A.query", Map);
List<String> imgList = new ArrayList<>();
for (int i = 0; i < docIdlist.size(); i++) {
Map dirId = new HashMap();
HPZL001A hpzl001A = docIdlist.get(i);
String docId = hpzl001A.getDocId();
dirId.put("docId", docId);
List<Map> query = this.dao.query("HPMT002.queryFile", dirId);
File file = new File(UploadUtils.ROOT_PATH + "/A/" + query.get(0).get("CHG_NAME"));
BufferedImage bf = ImageIO.read(file);
String imgBase64 = UploadUtils.imageToBase64(bf);
imgList.add(imgBase64);
}
Map sqlMap = new HashMap();
sqlMap.put("companyCode", companyCode);
sqlMap.put("id", id);
List<Map> rows = this.dao.query("HPMT002.pmQualityDetail", sqlMap);
EiBlock eiBlock = new EiBlock(EiConstant.resultBlock);
eiBlock.setRows(rows);
outInfo.setBlock(eiBlock);
outInfo.set("img",imgList);
} catch (Exception e){
outInfo.setMsg("账号异常");
}
return outInfo;
}
......@@ -146,17 +176,31 @@ public class ServiceHPMT002 extends ServiceBase {
* @return
*/
public EiInfo pmQualityXl(EiInfo inInfo) {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String factoryId= inInfo.getString("factoryId");//工厂id
String prodCode = inInfo.getString("projCode");//项目id
String orgNo = inInfo.getString("orgNo");//生产组id
String inventCode = inInfo.getString("inventCode");//部件id
String subInventCode = inInfo.getString("subInventCode");//部件id
String companyCode = UserSessionUtils.getCompanyCode();
if (StrUtil.isEmpty(companyCode)) {
inInfo.setMsg("账号异常");
}
Map sqlMap = new HashMap();
sqlMap.put("companyCode", companyCode);
sqlMap.put("factoryCode", factoryId);
sqlMap.put("orgNo", orgNo);
sqlMap.put("prodCode", prodCode);
sqlMap.put("parentPrdtCode", inventCode);
sqlMap.put("subInventCode", subInventCode);
EiInfo outInfo = new EiInfo();
CommonMethod.initBlock(outInfo, Arrays.asList(DdynamicEnum.ORG_PROD_BLOCK_ID), sqlMap, false);
CommonMethod.initBlock(outInfo, Arrays.asList(DdynamicEnum.PROJ_RECORD_BLOCK_ID), sqlMap, false);
TEDCM01 tedcm01 = new TEDCM01();
CommonMethod.initBlock(outInfo, Arrays.asList(DdynamicEnum.FACTORY_RECORD_BLOCK_ID), null, false);
CommonMethod.initBlock(outInfo, Arrays.asList(DdynamicEnum.PROJ_PRODQUERY_BLOCK_ID), sqlMap, false);
CommonMethod.initBlock(outInfo, Arrays.asList(DdynamicEnum.PROJ_QUERYPROD_BLOCK_ID), sqlMap, false);
CommonMethod.initBlock(outInfo, Arrays.asList(DdynamicEnum.INVENT_RECORD_BLOCK_ID), sqlMap, false);
CommonMethod.initBlock(outInfo, Arrays.asList(DdynamicEnum.GROUP_PRO_BLOCK_ID), sqlMap, false);
CommonMethod.initBlock(outInfo, Arrays.asList(DdynamicEnum.SUB_INVENT_RECORD_BLOCK_ID), sqlMap, false);
CommonMethod.initBlock(outInfo, Arrays.asList(DdynamicEnum.POOR_TYPE_BLOCK_ID), null, false);
return outInfo;
}
......@@ -167,54 +211,49 @@ public class ServiceHPMT002 extends ServiceBase {
* @return
*/
public EiInfo pmInsertQuality(EiInfo inInfo) {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String projCode = MapUtils.getString(queryMap, "projCode");
String prodOrderNo = MapUtils.getString(queryMap, "prodOrderNo");
String docId = MapUtils.getString(queryMap, "docId");
String docId = inInfo.getString("docId");
String companyCode = UserSessionUtils.getCompanyCode();
if (StrUtil.isEmpty(companyCode)) {
inInfo.setMsg("账号异常");
}
try {
Map sqlMap = new HashMap();
sqlMap.put("companyCode", companyCode);
sqlMap.put("projCode", projCode);
sqlMap.put("prodOrderNo", prodOrderNo);
List<HPSC005> HPSC005 = dao.query("HPSC005.query", sqlMap);
HPZL001 fZl001 = new HPZL001();
Map attr = inInfo.getAttr();
fZl001.fromMap(attr);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
fZl001.fromMap(queryMap);
fZl001.setProjName(HPSC005.get(0).getProjName());
fZl001.setOrgName(HPSC005.get(0).getOrgName());
fZl001.setInventName(HPSC005.get(0).getPrdtName());
fZl001.setSubInventName(HPSC005.get(0).getPartName());
fZl001.setCreatedTime(sdf.format(new Date()));
fZl001.setReceiptDate(DateUtils.shortDate());
// 生成单据号
fZl001.setCompanyCode(companyCode);
User user = UserSessionUtils.getUser();
fZl001.setCheckUser(user.getUserName());
fZl001.setCheckNo(user.getUserId());
// 生成单据号
fZl001.setCheckNo(SequenceGenerator.getNextSequence(
HPConstant.SequenceId.HPZL001_NUMBER));
fZl001.setDeleteFlag(CommonConstant.YesNo.NO_0);
fZl001.setStatus(CommonConstant.YesNo.NO_0);
DaoUtils.insert(HPZL001.INSERT, fZl001);
//处理文件
if(!fZl001.getCheckNo().equals(" ")) {
if(!docId.equals("")) {
Map fZl0012 = new HashMap();
fZl0012.put("checkNo", fZl001.getCheckNo());
HPZL001 HPZL001 = (HPZL001) dao.query("HPZL001.query", fZl0012);
List<HPZL001> HPZL001 =dao.query("HPZL001.query", fZl0012);
//绑定文件
String[] docIds = docId.split(",");
int num = 0;
while (num <= docIds.length) {
HPSC002A HPSC002A = new HPSC002A();
HPSC002A.setBizType(CommonConstant.YesNo.NO_0.toString());
HPSC002A.setDocId(docIds[num]);
HPSC002A.setMatId(HPZL001.getId());
HPSC002A.setCompanyCode(companyCode);
DaoUtils.insert(HPSC002A.INSERT, HPSC002A);
while (num < docIds.length) {
HPZL001A HPZL001A = new HPZL001A();
HPZL001A.setDeptCode(CommonConstant.YesNo.YES);
HPZL001A.setDocType(CommonConstant.YesNo.NO_0);
HPZL001A.setBizType("XJ_WC");
HPZL001A.setDocId(docIds[num]);
HPZL001A.setCheckId(HPZL001.get(0).getId());
HPZL001A.setCompanyCode(companyCode);
DaoUtils.insert(HPZL001A.INSERT, HPZL001A);
num++;
}
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsg("新增成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "新增失败");
......@@ -230,30 +269,36 @@ public class ServiceHPMT002 extends ServiceBase {
* @return
*/
public EiInfo pmModifyQuality(EiInfo inInfo) {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String docId = MapUtils.getString(queryMap, "docId");
String docId = inInfo.getString("docId");
String companyCode = UserSessionUtils.getCompanyCode();
if (StrUtil.isEmpty(companyCode)) {
inInfo.setMsg("账号异常");
}
try {
HPZL001 fZl001 = new HPZL001();
fZl001.fromMap(queryMap);
Map attr = inInfo.getAttr();
fZl001.fromMap(attr);
// 去除日期字符串中的-
fZl001.setReceiptDate(StringUtil.removeHorizontalLine(fZl001.getReceiptDate()));
fZl001.setStatus(CommonConstant.YesNo.YES_1);
DaoUtils.update(HPSqlConstant.HPZL001.DO_PROCESS2, fZl001);
//绑定文件
if(!docId.equals(" ")) {
if(!docId.equals("")) {
Map fZl0012 = new HashMap();
fZl0012.put("checkNo", fZl001.getCheckNo());
List<HPZL001> HPZL001 =dao.query("HPZL001.query", fZl0012);
//绑定文件
String[] docIds = docId.split(",");
int num = 0;
while (num <= docIds.length) {
HPSC002A HPSC002A = new HPSC002A();
HPSC002A.setBizType(CommonConstant.YesNo.NO_0.toString());
HPSC002A.setDocId(docIds[num]);
HPSC002A.setMatId(fZl001.getId());
HPSC002A.setCompanyCode(companyCode);
DaoUtils.insert(HPSC002A.INSERT, HPSC002A);
while (num < docIds.length) {
HPZL001A HPZL001A = new HPZL001A();
HPZL001A.setDeptCode(CommonConstant.YesNo.YES);
HPZL001A.setDocType(CommonConstant.YesNo.YES_1);
HPZL001A.setBizType("XJ_CL");
HPZL001A.setDocId(docIds[num]);
HPZL001A.setCheckId(HPZL001.get(0).getId());
HPZL001A.setCompanyCode(companyCode);
DaoUtils.insert(HPZL001A.INSERT, HPZL001A);
num++;
}
}
......@@ -264,4 +309,30 @@ public class ServiceHPMT002 extends ServiceBase {
return inInfo;
}
/**
* 生产管理-文件上传
*
* @param inInfo
* @return
*/
public EiInfo pmUploadFile(EiInfo inInfo) {
String files = inInfo.getString("files");
String companyCode = UserSessionUtils.getCompanyCode();
if (StrUtil.isEmpty(companyCode)) {
inInfo.setMsg("账号异常");
}
try {
CommonsMultipartFile multipartFile = Base64ToMultipartFile.base64toMultipartFile(files);
JSONObject upload = UploadUtils.upload(multipartFile);
inInfo.set("id",upload.getString("docId"));
inInfo.setMsg("上传成功!");
}
catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "上传失败");
}
return inInfo;
}
}
......@@ -48,8 +48,16 @@
COUNT(POOR_TYPE) AS POOR_TYPE_NUM,<!-- 单种不良品类数量 -->
CONCAT( FORMAT(COUNT(POOR_TYPE)/ (
SELECT COUNT(*) FROM hpjx.t_hpzl001 WHERE
COMPANY_CODE=#companyCode# )* 100,2),'%') AS NUM
FROM hpjx.t_hpzl001 WHERE COMPANY_CODE= #companyCode# AND DELETE_FLAG =0
COMPANY_CODE=#companyCode# )* 100,2),'%') AS NUM,
ITEM_CNAME AS ITEM_CNAME
FROM hpjx.t_hpzl001 A LEFT JOIN (
SELECT
ITEM_CODE,
ITEM_CNAME
FROM iplat.TEDCM01
WHERE CODESET_CODE = 'hpjx.hpjx.poorType'
) B ON A.POOR_TYPE =B.ITEM_CODE
WHERE COMPANY_CODE= #companyCode# AND DELETE_FLAG =0
GROUP BY POOR_TYPE
</select>
......@@ -65,11 +73,21 @@
INVENT_NAME as "inventName", <!-- 部件名称 -->
SUB_INVENT_CODE as "subInventCode", <!-- 零件编码 -->
SUB_INVENT_NAME as "subInventName", <!-- 零件名称 -->
FACTORY_CODE as "factoryCode", <!-- 厂区编码 -->
FACTORY_NAME as "factoryName", <!-- 厂区名称 -->
ORG_NO as "orgNo", <!-- 生产组编码 -->
ORG_NAME as "orgName", <!-- 生产组名称 -->
POOR_TYPE as "poorType", <!-- 不良品类 -->
STATUS as "status" <!-- 单据状态 0未处理 1已处理 -->
FROM hpjx.t_hpzl001 WHERE COMPANY_CODE= #companyCode# AND STATUS=#status# AND DELETE_FLAG =0
STATUS as "status", <!-- 单据状态 0未处理 1已处理 -->
B.ITEM_CNAME AS "itemCname"
FROM hpjx.t_hpzl001 A LEFT JOIN (
SELECT
ITEM_CODE,
ITEM_CNAME
FROM iplat.TEDCM01
WHERE CODESET_CODE = 'hpjx.hpjx.poorType'
) B ON A.POOR_TYPE =B.ITEM_CODE
WHERE COMPANY_CODE= #companyCode# AND STATUS=#status# AND DELETE_FLAG =0
</select>
<select id="pmQualityDetail" resultClass="java.util.HashMap">
......@@ -84,15 +102,25 @@
INVENT_NAME as "inventName", <!-- 部件名称 -->
SUB_INVENT_CODE as "subInventCode", <!-- 零件编码 -->
SUB_INVENT_NAME as "subInventName", <!-- 零件名称 -->
FACTORY_CODE as "factoryCode", <!-- 厂区编码 -->
FACTORY_NAME as "factoryName", <!-- 厂区名称 -->
ORG_NO as "orgNo", <!-- 生产组编码 -->
ORG_NAME as "orgName", <!-- 生产组名称 -->
POOR_TYPE as "poorType", <!-- 不良品类 -->
PROBLEM_DESC as "problemDesc", <!-- 质量问题描述 -->
CHECK_USER as "checkUser", <!-- 检查人 -->
CHECK_USER_NAME as "checkUserName", <!-- 检查人名称 -->
STATUS as "status" <!-- 单据状态 0未处理 1已处理 -->
FROM hpjx.t_hpzl001 WHERE COMPANY_CODE= #companyCode# AND STATUS=#status#
AND DELETE_FLAG = 0 AND CHECK_NO = #checkNo#
STATUS as "status", <!-- 单据状态 0未处理 1已处理 -->
B.ITEM_CNAME AS "itemCname"
FROM hpjx.t_hpzl001 A LEFT JOIN (
SELECT
ITEM_CODE,
ITEM_CNAME
FROM iplat.TEDCM01
WHERE CODESET_CODE = 'hpjx.hpjx.poorType'
) B ON A.POOR_TYPE =B.ITEM_CODE
WHERE COMPANY_CODE= #companyCode#
AND DELETE_FLAG = 0 AND ID = #id#
</select>
<insert id="insert">
......@@ -109,6 +137,8 @@
INVENT_NAME, <!-- 部件名称 -->
SUB_INVENT_CODE, <!-- 零件编码 -->
SUB_INVENT_NAME, <!-- 零件名称 -->
FACTORY_CODE as "factoryCode", <!-- 厂区编码 -->
FACTORY_NAME as "factoryName", <!-- 厂区名称 -->
ORG_NO, <!-- 生产组编码 -->
ORG_NAME, <!-- 生产组名称 -->
POOR_TYPE, <!-- 不良品类 -->
......@@ -127,4 +157,9 @@
#createdBy#, #createdName#, #createdTime#, #deleteFlag#)
</insert>
<select id="queryFile" resultClass="java.util.HashMap">
SELECT CHG_NAME FROM iplat.TEUDM02 where DOC_ID=#docId#
</select>
</sqlMap>
package com.baosight.hpjx.hp.mt.untils;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
public class BASE64DecodedMultipartFile implements MultipartFile {
private final byte[] imgContent;
private final String header;
public BASE64DecodedMultipartFile(byte[] imgContent, String header) {
this.imgContent = imgContent;
this.header = header.split(";")[0];
}
@Override
public String getName() {
return System.currentTimeMillis() + Math.random() + "." + header.split("/")[1];
}
@Override
public String getOriginalFilename() {
return System.currentTimeMillis() + (int) Math.random() * 10000 + "." + header.split("/")[1];
}
@Override
public String getContentType() {
return header.split(":")[1];
}
@Override
public boolean isEmpty() {
return imgContent == null || imgContent.length == 0;
}
@Override
public long getSize() {
return imgContent.length;
}
@Override
public byte[] getBytes() throws IOException {
return imgContent;
}
@Override
public InputStream getInputStream() throws IOException {
return new ByteArrayInputStream(imgContent);
}
@Override
public void transferTo(File dest) throws IOException, IllegalStateException {
new FileOutputStream(dest).write(imgContent);
}
}
package com.baosight.hpjx.hp.mt.untils;
import org.apache.commons.fileupload.disk.DiskFileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.xerces.impl.dv.util.Base64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import sun.misc.BASE64Decoder;
import java.io.*;
public class Base64ToMultipartFile implements MultipartFile {
private static Logger logger = LoggerFactory.getLogger(Base64ToMultipartFile.class);
private final byte[] imgContent;
private final String header;
public Base64ToMultipartFile(byte[] imgContent, String header) {
this.imgContent = imgContent;
this.header = header.split(";")[0];
}
@Override
public String getName() {
return System.currentTimeMillis() + Math.random() + "." + header.split("/")[1];
}
@Override
public String getOriginalFilename() {
return System.currentTimeMillis() + (int) Math.random() * 10000 + "." + header.split("/")[1];
}
@Override
public String getContentType() {
return header.split(":")[1];
}
@Override
public boolean isEmpty() {
return imgContent == null || imgContent.length == 0;
}
@Override
public long getSize() {
return imgContent.length;
}
@Override
public byte[] getBytes() throws IOException {
return imgContent;
}
@Override
public InputStream getInputStream() throws IOException {
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(imgContent);
// 关闭流,不然文件会一直占用资源,无法对其操作
byteArrayInputStream.close();
return byteArrayInputStream;
}
@Override
public void transferTo(File dest) throws IOException, IllegalStateException {
FileOutputStream fileOutputStream = new FileOutputStream(dest);
fileOutputStream.write(imgContent);
// 关闭流,不然文件会一直占用资源,无法对其操作
fileOutputStream.close();
}
/**
* base64转multipartFile
*
* @param
* @return
*/
public static MultipartFile base64Convert(String base64) {
String[] baseStrs = base64.split(",");
BASE64Decoder decoder = new BASE64Decoder();
byte[] b = new byte[0];
try {
b = decoder.decodeBuffer(baseStrs[1]);
} catch (IOException e) {
e.printStackTrace();
}
for (int i = 0; i < b.length; ++i) {
if (b[i] < 0) {
b[i] += 256;
}
}
return new Base64ToMultipartFile(b, baseStrs[0]);
}
public static CommonsMultipartFile base64toMultipartFile(String base64filestr){
final File file = base64ToFile(base64filestr);
if(file.exists()){
logger.info("存在");
logger.info("长度"+file.length());
}
DiskFileItem item = (DiskFileItem)new DiskFileItemFactory().createItem(file.getName(), "image/jpeg", false, file.getName());
InputStream input = null;
try {
input = new FileInputStream(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
OutputStream os = null;
try {
os = item.getOutputStream();
int ret = input.read();
while ( ret != -1 )
{
os.write(ret);
ret = input.read();
}
os.flush();
} catch (IOException e) {
e.printStackTrace();
}
return new CommonsMultipartFile(item);
}
public static File base64ToFile(String base64) {
if(base64==null||"".equals(base64)) {
return null;
}
//getRealImgeStr 方法 截取bese64字符串 逗号后半部分有用的字符串
byte[] buff= Base64.decode(getRealImgeStr(base64));
File file=null;
FileOutputStream fout=null;
try {
file = File.createTempFile("tmp", ".jpg");
fout=new FileOutputStream(file);
fout.write(buff);
} catch (IOException e) {
e.printStackTrace();
}finally {
if(fout!=null) {
try {
fout.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return file;
}
public static String getRealImgeStr(String imgStr){
String[] str = imgStr.split(",");
return str[1];
}
}
package com.baosight.hpjx.hp.mt.untils;
import org.springframework.web.multipart.MultipartFile;
import sun.misc.BASE64Decoder;
import java.io.IOException;
public class Base64Utils {
public static MultipartFile base64ToMultipartFile (String s) {
MultipartFile image = null;
StringBuilder base64 = new StringBuilder("");
if (s != null && !"".equals(s)) {
base64.append(s);
String[] baseStrs = base64.toString().split(",");
BASE64Decoder decoder = new BASE64Decoder();
byte[] b = new byte[0];
try {
b = decoder.decodeBuffer(baseStrs[1]);
} catch (IOException e) {
e.printStackTrace();
}
for (int j = 0; j < b.length; ++j) {
if (b[j] < 0) {
b[j] += 256;
}
}
image = new BASE64DecodedMultipartFile(b, baseStrs[0]);
}
return image;
}
}
package com.baosight.hpjx.hp.mt.untils;
import com.baosight.iplat4j.core.data.ibatis.dao.Dao;
import com.baosight.iplat4j.core.data.id.UUIDHexIdGenerator;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.ioc.spring.PlatApplicationContext;
import com.baosight.iplat4j.core.util.DateUtils;
import com.baosight.iplat4j.core.util.StringUtils;
import com.baosight.iplat4j.core.web.threadlocal.UserSession;
import com.baosight.iplat4j.eu.dm.domain.EUDM02;
import com.baosight.iplat4j.eu.dm.util.FileProcessUtils;
import com.baosight.iplat4j.eu.dm.util.IFileUploader;
import net.sf.json.JSONObject;
import org.apache.commons.codec.binary.Base64;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class uploadUntil {
import static com.baosight.iplat4j.eu.dm.util.FileUploadConstant.VIRTUAL_ROOT;
public class UploadUtils {
public static String ROOT_PATH="C:/workspace/java/hp-smart/file";
private static String DEFAULT_INVALID_SUFFIX;
private static String MODULE_NAME="EP";
private static String PROJECT_NAME="HPJX";
private static String VIRTUAL_ROOT="HPJX_EP_$";
public static IFileUploader fileUploader;
public static String upload(CommonsMultipartFile multipartFile ) throws IOException {
private static Dao dao = (Dao)PlatApplicationContext.getApplicationContext().getBean("dao");
public static JSONObject upload(CommonsMultipartFile multipartFile ) throws IOException {
JSONObject documentJSON = new JSONObject();
String filePath;
String msg;
......@@ -25,9 +43,9 @@ public class uploadUntil {
String docPath;
filePath = multipartFile.getOriginalFilename();
Long docSize = multipartFile.getSize();
String chgName = fileUploader.transformFileName(filePath);
String chgName = transformFileName(filePath);
String attachmentName;
Map<String, String> pathMap = fileUploader.getRealPath("A");
Map<String, String> pathMap = getRealPath("A");
msg = (String)pathMap.get("dirId");
category = (String)pathMap.get("path");
checkInvalidPath(category);
......@@ -46,7 +64,7 @@ public class uploadUntil {
map.put("docSize", docSize);
map.put("recCreator", "");
map.put("recCreateTime", DateUtils.curDateTimeStr14());
fileUploader.uploadDoc(map);
uploadDoc(map);
attachmentName = category + "/" + chgName;
multipartFile.transferTo(new File(attachmentName));
documentJSON.put("docId", docPath);
......@@ -57,9 +75,56 @@ public class uploadUntil {
documentJSON.put("docUrl", attachmentName);
documentJSON.put("docSize", docSize);
documentJSON.put("docName", filePath);
return documentJSON;
}
private static String transformFileName(String originalFileName) {
String dateMselStr14 = DateUtils.curDateTimeStr14();
String uuid8 = FileProcessUtils.getShortUuid();
String chgFileName = dateMselStr14 + "_" + uuid8;
String dot = ".";
int index = originalFileName.lastIndexOf(dot);
String fileName;
if (index > 0) {
String suffix = originalFileName.substring(index + 1);
String invalidSuffixConfig = PlatApplicationContext.getProperty("iplat.upload.invalidSuffix");
if (!StringUtils.isNotEmpty(invalidSuffixConfig)) {
invalidSuffixConfig = DEFAULT_INVALID_SUFFIX;
}
String[] invalidSuffixs = invalidSuffixConfig.split(",");
String[] var11 = invalidSuffixs;
int var12 = invalidSuffixs.length;
for(int var13 = 0; var13 < var12; ++var13) {
String invalidSuffix = var11[var13];
if (suffix.equalsIgnoreCase(invalidSuffix)) {
throw new PlatException("文件扩展名不合法!");
}
}
fileName = chgFileName + dot + suffix;
} else {
fileName = chgFileName.toString();
}
return fileName;
}
public static Map<String, String> getRealPath(String path) {
String postPath = preparePath(path);
String dirId = initPath(postPath);
postPath = ROOT_PATH + "/" + postPath;
Map<String, String> map = new HashMap();
map.put("path", postPath);
map.put("dirId", dirId);
return map;
}
return "";
public static String preparePath(String path) {
return path;
}
public static void checkInvalidPath(String realPath) {
......@@ -83,4 +148,91 @@ public class uploadUntil {
}
}
public static String initPath(String path) {
String[] dirs = path.split("/");
String parentId = VIRTUAL_ROOT;
String dirPath = VIRTUAL_ROOT;
String dirId = null;
String realPath = "";
try {
for(int i = 0; i < dirs.length; ++i) {
HashMap<String, String> pathMap = new HashMap();
pathMap.put("parentId", parentId);
pathMap.put("dirEname", dirs[i]);
pathMap.put("moduleEname", MODULE_NAME);
pathMap.put("projectEname", PROJECT_NAME);
List pathList = dao.query("EUDM01.queryPath", pathMap);
realPath = realPath + dirs[i] + "/";
if (pathList.size() == 0) {
Map<String, String> dirRow = new HashMap();
String userId = String.valueOf(UserSession.getUserId());
String dateTime = DateUtils.curDateTimeStr14();
dirId = UUIDHexIdGenerator.generate().toString();
dirPath = dirPath + "." + dirId;
dirRow.put("dirId", dirId);
dirRow.put("dirEname", dirs[i]);
dirRow.put("dirCname", dirs[i]);
dirRow.put("parentId", parentId);
dirRow.put("isLeaf", i == dirs.length - 1 ? "1" : "0");
dirRow.put("dirPath", dirPath);
dirRow.put("projectEname", PROJECT_NAME);
dirRow.put("moduleEname", MODULE_NAME);
dirRow.put("recCreator", userId);
dirRow.put("recCreateTime", dateTime);
dirRow.put("recRevisor", " ");
dirRow.put("recReviseTime", " ");
dirRow.put("archiveFlag", " ");
dirRow.put("archiveFlag", " ");
dirRow.put("realPath", realPath);
dao.insert("EUDM01.insert", dirRow);
Map<String, String> dirMap = new HashMap();
dirMap.put("dirId", parentId);
List list = dao.query("EUDM01.query", dirMap);
if (null != list && list.size() > 0) {
Map<String, String> item = (Map)list.get(0);
if ("1".equals(item.get("isLeaf"))) {
item.put("isLeaf", "0");
dao.update("EUDM01.update", list.get(0));
}
}
parentId = dirId;
} else {
Map<String, String> item = (Map)pathList.get(0);
parentId = (String)item.get("dirId");
dirId = (String)item.get("dirId");
dirPath = (String)item.get("dirPath");
}
}
return dirId;
} catch (Exception var16) {
throw new PlatException("上传附件,创建目录: " + path + " 失败!", var16);
}
}
public static boolean uploadDoc(Map docMap) {
EUDM02 document = new EUDM02();
document.fromMap(docMap);
try {
dao.insert("EUDM02.insert", document);
boolean success = true;
return success;
} catch (Exception var5) {
throw new PlatException("保存附件 " + docMap.get("docName") + " 失败!", var5);
}
}
public static String imageToBase64(BufferedImage bufferedImage) {
Base64 encoder = new Base64();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
ImageIO.write(bufferedImage, "jpg", baos);
} catch (IOException e) {
}
return new String(encoder.encode((baos.toByteArray())));
}
}
......@@ -333,6 +333,40 @@
ORDER BY PROJ_CODE
</select>
<!-- 项目下拉框 -->
<select id="queryProjComboBox2" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
SELECT DISTINCT
A.PROJ_CODE as "projCode",
A.PROJ_NAME as "projName",
A.PROD_ORDER_NO AS "prodOrderNo",
B.PROD_TASK_NO AS "prodTaskNo"
FROM ${hpjxSchema}.T_HPSC005 A LEFT JOIN ${hpjxSchema}.T_HPSC005A B ON A.COMPANY_CODE=B.COMPANY_CODE
AND A.PROD_ORDER_NO=B.PROD_ORDER_NO
WHERE 1=1
<isNotEmpty prepend=" AND " property="companyCode">
A.COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="projCode">
A.PROJ_CODE = #projCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="status">
A.STATUS = #status#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="factoryCode">
B.FACTORY_CODE = #factoryCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="orgNo">
B.ORG_NO = #orgNo#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="parentPrdtCode">
A.PRDT_CODE = #parentPrdtCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="subInventCode">
A.PART_CODE = #subInventCode#
</isNotEmpty>
ORDER BY A.PROJ_CODE
</select>
<!-- 生产组下拉框 -->
<select id="queryOrgComboBox" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
SELECT
......
......@@ -165,7 +165,10 @@
ORG_CNAME
FROM iplat.TXSOG01 WHERE COMPANY_CODE=#companyCode#
) B ON A.PARENT_ORG_ID=B.ORG_ENAME
WHERE A.ORG_TYPE = 'cutGroup' AND A.COMPANY_CODE=#companyCode#
WHERE A.ORG_TYPE = 'prodGroup' AND A.COMPANY_CODE=#companyCode#
<isNotEmpty prepend=" AND " property="factoryCode">
A.PARENT_ORG_ID=#factoryCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="factoryName">
B.ORG_CNAME LIKE CONCAT('%', #factoryName#, '%')
</isNotEmpty>
......@@ -174,4 +177,15 @@
</isNotEmpty>
</select>
<!-- 查询组织信息 -->
<select id="queryTedcm01" resultClass="com.baosight.iplat4j.common.ed.domain.TEDCM01">
SELECT
ITEM_CODE AS "itemCode",
ITEM_CNAME AS "itemCname"
FROM iplat.TEDCM01
WHERE CODESET_CODE = 'hpjx.hpjx.poorType'
</select>
</sqlMap>
......@@ -48,7 +48,9 @@ public class HPZL001 extends DaoEPBase {
public static final String FIELD_UPDATED_NAME = "updatedName"; /* 更新人名称*/
public static final String FIELD_UPDATED_TIME = "updatedTime"; /* 更新时间*/
public static final String FIELD_DELETE_FLAG = "deleteFlag"; /* 是否删除*/
public static final String FIELD_FACTORY_CODE = "factoryCode"; /* 厂区编码*/
public static final String FIELD_FACTORY_NAME = "factoryName"; /* 厂区名称*/
public static final String COL_ID = "ID";
public static final String COL_COMPANY_CODE = "COMPANY_CODE"; /* 企业编码 预留*/
public static final String COL_DEP_CODE = "DEP_CODE"; /* 部门编码*/
......@@ -76,6 +78,8 @@ public class HPZL001 extends DaoEPBase {
public static final String COL_UPDATED_NAME = "UPDATED_NAME"; /* 更新人名称*/
public static final String COL_UPDATED_TIME = "UPDATED_TIME"; /* 更新时间*/
public static final String COL_DELETE_FLAG = "DELETE_FLAG"; /* 是否删除*/
public static final String COL_FACTORY_CODE = "FACTORY_CODE"; /* 厂区编码*/
public static final String COL_FACTORY_NAME = "FACTORY_NAME"; /* 厂区名称*/
public static final String QUERY = "HPZL001.query";
public static final String COUNT = "HPZL001.count";
......@@ -110,6 +114,8 @@ public class HPZL001 extends DaoEPBase {
private String updatedName = " "; /* 更新人名称*/
private String updatedTime = " "; /* 更新时间*/
private Integer deleteFlag; /* 是否删除*/
private String factoryCode = " "; /* 厂区编码*/
private String factoryName = " "; /* 厂区名称*/
/**
* initialize the metadata.
......@@ -225,6 +231,14 @@ public class HPZL001 extends DaoEPBase {
eiColumn = new EiColumn(FIELD_DELETE_FLAG);
eiColumn.setDescName("是否删除");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_FACTORY_CODE);
eiColumn.setDescName("厂区编码");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_FACTORY_NAME);
eiColumn.setDescName("厂区名称");
eiMetadata.addMeta(eiColumn);
}
......@@ -669,6 +683,38 @@ public class HPZL001 extends DaoEPBase {
this.deleteFlag = deleteFlag;
}
/**
* get the factoryCode - 厂区编码.
* @return the factoryCode
*/
public String getFactoryCode() {
return this.factoryCode;
}
/**
* set the factoryCode - 厂区编码.
*
* @param factoryCode - 厂区编码
*/
public void setFactoryCode(String factoryCode) {
this.factoryCode = factoryCode;
}
/**
* get the factoryName - 厂区名称.
* @return the factoryName
*/
public String getFactoryName() {
return this.factoryName;
}
/**
* set the factoryName - 厂区名称.
*
* @param factoryName - 厂区名称
*/
public void setFactoryName(String factoryName) {
this.factoryName = factoryName;
}
/**
* get the value from Map.
*
* @param map - source data map
......@@ -703,6 +749,8 @@ public class HPZL001 extends DaoEPBase {
setUpdatedName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_UPDATED_NAME)), updatedName));
setUpdatedTime(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_UPDATED_TIME)), updatedTime));
setDeleteFlag(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_DELETE_FLAG)), deleteFlag));
setFactoryCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_FACTORY_CODE)), factoryCode));
setFactoryName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_FACTORY_NAME)), factoryName));
}
/**
......@@ -739,7 +787,8 @@ public class HPZL001 extends DaoEPBase {
map.put(FIELD_UPDATED_NAME, StringUtils.toString(updatedName, eiMetadata.getMeta(FIELD_UPDATED_NAME)));
map.put(FIELD_UPDATED_TIME, StringUtils.toString(updatedTime, eiMetadata.getMeta(FIELD_UPDATED_TIME)));
map.put(FIELD_DELETE_FLAG, StringUtils.toString(deleteFlag, eiMetadata.getMeta(FIELD_DELETE_FLAG)));
map.put(FIELD_FACTORY_CODE, StringUtils.toString(factoryCode, eiMetadata.getMeta(FIELD_FACTORY_CODE)));
map.put(FIELD_FACTORY_NAME, StringUtils.toString(factoryName, eiMetadata.getMeta(FIELD_FACTORY_NAME)));
return map;
}
}
......@@ -35,6 +35,7 @@ public class HPZL001A extends DaoEPBase {
public static final String FIELD_UPDATED_BY = "updatedBy"; /* 修改人*/
public static final String FIELD_UPDATED_NAME = "updatedName"; /* 修改人名称*/
public static final String FIELD_UPDATED_TIME = "updatedTime"; /* 修改时间*/
public static final String FIELD_BIZ_TYPE = "bizType"; /* 业务类型*/
public static final String COL_ID = "ID"; /* 主键ID*/
public static final String COL_COMPANY_CODE = "COMPANY_CODE"; /* 企业编码 预留*/
......@@ -49,6 +50,7 @@ public class HPZL001A extends DaoEPBase {
public static final String COL_UPDATED_BY = "UPDATED_BY"; /* 修改人*/
public static final String COL_UPDATED_NAME = "UPDATED_NAME"; /* 修改人名称*/
public static final String COL_UPDATED_TIME = "UPDATED_TIME"; /* 修改时间*/
public static final String COL_BIZ_TYPE = "BIZ_TYPE"; /* 业务类型*/
public static final String QUERY = "HPZL001A.query";
public static final String COUNT = "HPZL001A.count";
......@@ -69,6 +71,7 @@ public class HPZL001A extends DaoEPBase {
private String updatedBy = " "; /* 修改人*/
private String updatedName = " "; /* 修改人名称*/
private String updatedTime = " "; /* 修改时间*/
private String bizType = " "; /* 业务类型*/
/**
* initialize the metadata.
......@@ -129,6 +132,10 @@ public class HPZL001A extends DaoEPBase {
eiColumn.setDescName("修改时间");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_BIZ_TYPE);
eiColumn.setDescName("业务类型");
eiMetadata.addMeta(eiColumn);
}
......@@ -348,6 +355,22 @@ public class HPZL001A extends DaoEPBase {
this.updatedTime = updatedTime;
}
/**
* get the bizType - 业务类型.
* @return the bizType
*/
public String getBizType() {
return this.bizType;
}
/**
* set the bizType - 业务类型.
*
* @param bizType - 业务类型
*/
public void setBizType(String bizType) {
this.bizType = bizType;
}
/**
* get the value from Map.
*
* @param map - source data map
......@@ -368,6 +391,7 @@ public class HPZL001A extends DaoEPBase {
setUpdatedBy(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_UPDATED_BY)), updatedBy));
setUpdatedName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_UPDATED_NAME)), updatedName));
setUpdatedTime(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_UPDATED_TIME)), updatedTime));
setBizType(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_BIZ_TYPE)), bizType));
}
/**
......@@ -390,6 +414,7 @@ public class HPZL001A extends DaoEPBase {
map.put(FIELD_UPDATED_BY, StringUtils.toString(updatedBy, eiMetadata.getMeta(FIELD_UPDATED_BY)));
map.put(FIELD_UPDATED_NAME, StringUtils.toString(updatedName, eiMetadata.getMeta(FIELD_UPDATED_NAME)));
map.put(FIELD_UPDATED_TIME, StringUtils.toString(updatedTime, eiMetadata.getMeta(FIELD_UPDATED_TIME)));
map.put(FIELD_BIZ_TYPE, StringUtils.toString(bizType, eiMetadata.getMeta(FIELD_BIZ_TYPE)));
return map;
}
......
......@@ -128,6 +128,8 @@ public class ServiceHPZL001B extends ServiceEPBase {
newZl001.setDeleteFlag(CommonConstant.YesNo.NO_0);
newZl001.setCheckUser(UserSession.getLoginName());
newZl001.setCheckUserName(UserSession.getLoginCName());
newZl001.setFactoryCode(dbSc005b.getFactoryCode());
newZl001.setFactoryName(dbSc005b.getFactoryName());
DaoUtils.insert(HPZL001.INSERT, newZl001);
}
} catch (Exception e) {
......
......@@ -12,6 +12,8 @@
PROD_TASK_NO as "prodTaskNo", <!-- 生产任务号 -->
PROJ_CODE as "projCode", <!-- 项目号 -->
PROJ_NAME as "projName", <!-- 项目名称 -->
FACTORY_CODE as "factoryCode", <!-- 厂区编码 -->
FACTORY_NAME as "factoryName", <!-- 厂区名称 -->
INVENT_CODE as "inventCode", <!-- 部件编码 -->
INVENT_NAME as "inventName", <!-- 部件名称 -->
SUB_INVENT_CODE as "subInventCode", <!-- 零件编码 -->
......@@ -138,6 +140,8 @@
INVENT_NAME, <!-- 部件名称 -->
SUB_INVENT_CODE, <!-- 零件编码 -->
SUB_INVENT_NAME, <!-- 零件名称 -->
FACTORY_CODE, <!-- 厂区编码 -->
FACTORY_NAME, <!-- 厂区名称 -->
ORG_NO, <!-- 生产组编码 -->
ORG_NAME, <!-- 生产组名称 -->
POOR_TYPE, <!-- 不良品类 -->
......@@ -151,7 +155,7 @@
DELETE_FLAG <!-- 是否删除 -->
) VALUES (
#companyCode#, #depCode#, #receiptDate#, #checkNo#, #prodOrderNo#, #prodTaskNo#,
#projCode#, #projName#, #inventCode#, #inventName#, #subInventCode#, #subInventName#,
#projCode#, #projName#, #inventCode#, #inventName#, #subInventCode#, #subInventName#,#factoryCode#,#factoryName#,
#orgNo#, #orgName#, #poorType#, #problemDesc#,#checkUser#,#checkUserName#, #status#,
#createdBy#, #createdName#, #createdTime#, #deleteFlag#)
</insert>
......
......@@ -15,7 +15,7 @@
A.CREATED_TIME as "createdTime", <!-- 创建时间 -->
A.UPDATED_BY as "updatedBy", <!-- 修改人 -->
A.UPDATED_NAME as "updatedName", <!-- 修改人名称 -->
A.UPDATED_TIME as "updatedTime" <!-- 修改时间 -->
A.UPDATED_TIME as "updatedTime"<!-- 修改时间 -->
</sql>
<sql id="condition">
......
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