Commit 538be61e by liulei

生产下料高度锁定优化

parent ce5a17c4
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.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.zl.domain.HPZL001;
import com.baosight.hpjx.util.EiInfoUtils;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.StringUtil;
import com.baosight.iplat4j.config.AdminFactoryConfig;
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 org.apache.commons.collections.MapUtils;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 鸿鹏机械APP移动端接口调用处
*/
public class ServiceHPMT002 extends ServiceBase {
/**
* 画面初始化
*
* @param inInfo
* @return
*/
public EiInfo initLoad(EiInfo inInfo) {
return inInfo;
}
/**
* 生产管理-项⽬跟踪
*
* @param inInfo
* @return
*/
public EiInfo pmProject(EiInfo inInfo) {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String companyCode = UserSessionUtils.getCompanyCode();
if (StrUtil.isEmpty(companyCode)) {
inInfo.setMsg("账号异常");
}
Map sqlMap = new HashMap();
sqlMap.put("companyCode", companyCode);
List<Map> rows = this.dao.query("HPMT002.pmProject", sqlMap);
EiInfo outInfo = new EiInfo();
EiBlock eiBlock = new EiBlock(EiConstant.resultBlock);
eiBlock.setRows(rows);
outInfo.setBlock(eiBlock);
return outInfo;
}
/**
* 生产管理-质量分析报表
*
* @param inInfo
* @return
*/
public EiInfo pmQuality(EiInfo inInfo) {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String companyCode = UserSessionUtils.getCompanyCode();
if (StrUtil.isEmpty(companyCode)) {
inInfo.setMsg("账号异常");
}
Map sqlMap = new HashMap();
sqlMap.put("companyCode", companyCode);
List<Map> rows = this.dao.query("HPMT002.pmQuality", sqlMap);
EiInfo outInfo = new EiInfo();
EiBlock eiBlock = new EiBlock(EiConstant.resultBlock);
eiBlock.setRows(rows);
outInfo.setBlock(eiBlock);
return outInfo;
}
/**
* 生产管理-质量巡检列表-项目列表
*
* @param inInfo
* @return
*/
public EiInfo pmQualityList(EiInfo inInfo) {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String status = MapUtils.getString(queryMap, "status");
String companyCode = UserSessionUtils.getCompanyCode();
if (StrUtil.isEmpty(companyCode)) {
inInfo.setMsg("账号异常");
}
Map sqlMap = new HashMap();
sqlMap.put("companyCode", companyCode);
sqlMap.put("status", status);
List<Map> rows = this.dao.query("HPMT002.pmQualityList", sqlMap);
EiInfo outInfo = new EiInfo();
EiBlock eiBlock = new EiBlock(EiConstant.resultBlock);
eiBlock.setRows(rows);
outInfo.setBlock(eiBlock);
return outInfo;
}
/**
* 生产管理-质量巡检列表-项目详情
*
* @param inInfo
* @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);
return outInfo;
}
/**
* 生产管理-质量巡检新增
*
* @param inInfo
* @return
*/
public EiInfo pmInsertQuality(EiInfo inInfo) {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String companyCode = UserSessionUtils.getCompanyCode();
if (StrUtil.isEmpty(companyCode)) {
inInfo.setMsg("账号异常");
}
try {
HPZL001 fZl001 = new HPZL001();
fZl001.fromMap(queryMap);
//处理文件
CommonsMultipartFile[] multipartFile = (CommonsMultipartFile[]) queryMap.get("multipartFile");
int num=0;
while (num<=multipartFile.length){
try {
uploadUntil.upload(multipartFile[num]);
}catch (Exception e){
LogUtils.setDetailMsg(inInfo, e, "上传失败");
}
num++;
}
// 去除日期字符串中的-
fZl001.setReceiptDate(StringUtil.removeHorizontalLine(fZl001.getReceiptDate()));
// 生成单据号
fZl001.setCheckNo(SequenceGenerator.getNextSequence(
HPConstant.SequenceId.HPZL001_NUMBER));
fZl001.setDeleteFlag(CommonConstant.YesNo.NO_0);
DaoUtils.insert(HPZL001.INSERT, fZl001);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("新增成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "新增失败");
}
return inInfo;
}
/**
* 生产管理-质量巡检处理
*
* @param inInfo
* @return
*/
public EiInfo pmModifyQuality(EiInfo inInfo) {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String companyCode = UserSessionUtils.getCompanyCode();
if (StrUtil.isEmpty(companyCode)) {
inInfo.setMsg("账号异常");
}
try {
HPZL001 fZl001 = new HPZL001();
fZl001.fromMap(queryMap);
//处理文件
// 去除日期字符串中的-
fZl001.setReceiptDate(StringUtil.removeHorizontalLine(fZl001.getReceiptDate()));
fZl001.setDeleteFlag(CommonConstant.YesNo.YES_1);
DaoUtils.update(HPSqlConstant.HPZL001.DO_PROCESS, fZl001);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("新增成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "新增失败");
}
return inInfo;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="HPMT002">
<select id="pmProject" resultClass="java.util.HashMap">
SELECT
ID as "id",
COMPANY_CODE as "companyCode", <!-- 企业编码 预留 -->
PROJ_TYPE as "projType", <!-- 项目类型 -->
PROJ_CODE as "projCode", <!-- 项目编码 -->
PROJ_NAME as "projName", <!-- 项目名称 -->
PLAN_INFO_NO as "planInfoNo", <!-- 生产计划单号 -->
PLAN_COMPLETION_DATE as "planCompletionDate", <!-- 计划完成日期 -->
STATUS as "status", <!-- 状态 0-计划中,1-生产中 -->
CONCAT((
SELECT
format((ifnull( SUM( ACTUAL_COMPLETION_NUM ), 0 ) / ifnull( SUM( NUM ), 0 ) * 100),2)
FROM
hpjx.T_HPSC004
WHERE
PARENT_ID = hpjx.T_HPSC003.PLAN_INFO_NO
),'%') AS "schedule", <!-- 进度 -->
(
SELECT
IFNULL( SUM( ACTUAL_COMPLETION_NUM ), 0 )
FROM
hpjx.T_HPSC004
WHERE
PARENT_ID = hpjx.T_HPSC003.PLAN_INFO_NO
) AS "actualCompletionNum" <!-- 完成数量 -->
,
(
SELECT
IFNULL( SUM( NUM ),2)
FROM
hpjx.T_HPSC004
WHERE
PARENT_ID = hpjx.T_HPSC003.PLAN_INFO_NO
) AS "num" <!-- 计划数量 -->
FROM hpjx.T_HPSC003 WHERE COMPANY_CODE= #companyCode#
</select>
<select id="pmQuality" resultClass="java.util.HashMap">
SELECT
POOR_TYPE,<!-- 不良品类 -->
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
GROUP BY POOR_TYPE
</select>
<select id="pmQualityList" resultClass="java.util.HashMap">
SELECT
ID as "id",
CHECK_NO as "checkNo", <!-- 检查单号 -->
PROD_ORDER_NO as "prodOrderNo", <!-- 生产订单号 -->
PROD_TASK_NO as "prodTaskNo", <!-- 生产任务号 -->
PROJ_CODE as "projCode", <!-- 项目号 -->
PROJ_NAME as "projName", <!-- 项目名称 -->
INVENT_CODE as "inventCode", <!-- 部件编码 -->
INVENT_NAME as "inventName", <!-- 部件名称 -->
SUB_INVENT_CODE as "subInventCode", <!-- 零件编码 -->
SUB_INVENT_NAME as "subInventName", <!-- 零件名称 -->
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
</select>
<select id="pmQualityDetail" resultClass="java.util.HashMap">
SELECT
ID as "id",
CHECK_NO as "checkNo", <!-- 检查单号 -->
PROD_ORDER_NO as "prodOrderNo", <!-- 生产订单号 -->
PROD_TASK_NO as "prodTaskNo", <!-- 生产任务号 -->
PROJ_CODE as "projCode", <!-- 项目号 -->
PROJ_NAME as "projName", <!-- 项目名称 -->
INVENT_CODE as "inventCode", <!-- 部件编码 -->
INVENT_NAME as "inventName", <!-- 部件名称 -->
SUB_INVENT_CODE as "subInventCode", <!-- 零件编码 -->
SUB_INVENT_NAME as "subInventName", <!-- 零件名称 -->
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#
</select>
<insert id="insert">
INSERT INTO hpjx.t_hpzl001 (
COMPANY_CODE, <!-- 企业编码 预留 -->
DEP_CODE, <!-- 部门编码 -->
RECEIPT_DATE, <!-- 单据日期 -->
CHECK_NO, <!-- 检查单号 -->
PROD_ORDER_NO, <!-- 生产订单号 -->
PROD_TASK_NO, <!-- 生产任务号 -->
PROJ_CODE, <!-- 项目号 -->
PROJ_NAME, <!-- 项目名称 -->
INVENT_CODE, <!-- 部件编码 -->
INVENT_NAME, <!-- 部件名称 -->
SUB_INVENT_CODE, <!-- 零件编码 -->
SUB_INVENT_NAME, <!-- 零件名称 -->
ORG_NO, <!-- 生产组编码 -->
ORG_NAME, <!-- 生产组名称 -->
POOR_TYPE, <!-- 不良品类 -->
PROBLEM_DESC, <!-- 质量问题描述 -->
CHECK_USER , <!-- 检查人 -->
CHECK_USER_NAME, <!-- 检查人名称 -->
STATUS, <!-- 单据状态 0未处理 1已处理 -->
CREATED_BY, <!-- 创建人 -->
CREATED_NAME, <!-- 创建人名称 -->
CREATED_TIME, <!-- 创建时间 -->
DELETE_FLAG <!-- 是否删除 -->
) VALUES (
#companyCode#, #depCode#, #receiptDate#, #checkNo#, #prodOrderNo#, #prodTaskNo#,
#projCode#, #projName#, #inventCode#, #inventName#, #subInventCode#, #subInventName#,
#orgNo#, #orgName#, #poorType#, #problemDesc#,#checkUser#,#checkUserName#, #status#,
#createdBy#, #createdName#, #createdTime#, #deleteFlag#)
</insert>
</sqlMap>
package com.baosight.hpjx.hp.mt.untils;
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.eu.dm.util.IFileUploader;
import net.sf.json.JSONObject;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
public class uploadUntil {
public static IFileUploader fileUploader;
public static String upload(CommonsMultipartFile multipartFile ) throws IOException {
JSONObject documentJSON = new JSONObject();
String filePath;
String msg;
String category;
String docPath;
filePath = multipartFile.getOriginalFilename();
Long docSize = multipartFile.getSize();
String chgName = fileUploader.transformFileName(filePath);
String attachmentName;
Map<String, String> pathMap = fileUploader.getRealPath("A");
msg = (String)pathMap.get("dirId");
category = (String)pathMap.get("path");
checkInvalidPath(category);
File dir = new File(category);
if (!dir.exists()) {
dir.mkdirs();
}
docPath = UUIDHexIdGenerator.generate().toString();
Map map = new HashMap();
map.put("docId", docPath);
map.put("dirId", msg);
map.put("docTag", "");
map.put("docName", filePath);
map.put("chgName", chgName);
map.put("docSize", docSize);
map.put("recCreator", "");
map.put("recCreateTime", DateUtils.curDateTimeStr14());
fileUploader.uploadDoc(map);
attachmentName = category + "/" + chgName;
multipartFile.transferTo(new File(attachmentName));
documentJSON.put("docId", docPath);
documentJSON.put("docTag", "");
documentJSON.put("author", "");
documentJSON.put("authorCName", "");
documentJSON.put("uploadTime", DateUtils.toDateTimeStr14(new Date()));
documentJSON.put("docUrl", attachmentName);
documentJSON.put("docSize", docSize);
documentJSON.put("docName", filePath);
return "";
}
public static void checkInvalidPath(String realPath) {
String pathErrorMsg = "Upload params contain invalid characters!";
if (realPath.contains("../")) {
throw new PlatException(pathErrorMsg);
} else {
String invalidPathConfig = PlatApplicationContext.getProperty("iplat.upload.invalidPath");
if (StringUtils.isNotEmpty(invalidPathConfig)) {
String[] invalidPaths = invalidPathConfig.split(",");
String[] var5 = invalidPaths;
int var6 = invalidPaths.length;
for(int var7 = 0; var7 < var6; ++var7) {
String invalidPath = var5[var7];
if (realPath.contains(invalidPath)) {
throw new PlatException(pathErrorMsg);
}
}
}
}
}
}
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<EF:EFRegion id="result" title="生产任务集"> <EF:EFRegion id="result" title="生产任务集">
<EF:EFGrid blockId="result" autoDraw="no" checkMode="row,single" > <EF:EFGrid blockId="result" autoDraw="no" height="30vh" checkMode="row,single" >
<EF:EFColumn ename="id" cname="主键" hidden="true"/> <EF:EFColumn ename="id" cname="主键" hidden="true"/>
<EF:EFColumn enable="false" ename="projCode" cname="项目号" /> <EF:EFColumn enable="false" ename="projCode" cname="项目号" />
<EF:EFColumn enable="false" ename="projName" cname="项目名称"/> <EF:EFColumn enable="false" ename="projName" cname="项目名称"/>
......
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