Commit ddb8ce7d by 宋祥

Merge branch 'dev' of http://129.211.46.84:8800/platform/hp-smart

 Conflicts:
	src/main/resources/application.properties
	src/main/resources/quartz.properties
parents 2f343c84 592fef70
package com.baosight.hpjx.aspect.annotation;
import com.baosight.hpjx.aspect.domain.TCPReceive;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.web.controller.WebDispatchController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -16,7 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/tcp")
public class TCPController extends WebDispatchController {
private final static Logger logger = LoggerFactory.getLogger(DocController.class);
private final static Logger logger = LoggerFactory.getLogger(TCPController.class);
@RequestMapping(value = "/receive/api", method = RequestMethod.POST)
......
......@@ -392,6 +392,8 @@ public enum DdynamicEnum {
* 编写:ly
*/
DEVICE_CODE_BLOCK_ID("deviceCode_block_id","deviceCode","deviceName","HPSB003.queryDeviceCode"),
DEVICE_CODE_BOX_BLOCK_ID("deviceCodeBox_block_id","deviceCode","deviceName", "deviceType", "companyCode", "factoryCode", "groupCode","deviceStatus","HPSB003.queryDeviceCodeBox"),
;
......
package com.baosight.hpjx.aspect.annotation;
package com.baosight.hpjx.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baosight.hpjx.core.enums.DocRouteEnum;
import com.baosight.hpjx.util.DocExcelUtils;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.MapUtils;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.soa.XLocalManager;
import com.baosight.iplat4j.core.web.controller.WebDispatchController;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.Args;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import com.baosight.hpjx.common.DocRouteEnum;
/**
* DOC 接口类
*
......@@ -63,7 +38,7 @@ import com.baosight.hpjx.common.DocRouteEnum;
@RequestMapping("/doc")
public class DocController extends WebDispatchController {
private final static Logger logger = LoggerFactory.getLogger(DocController.class);
private final static Logger log = LoggerFactory.getLogger(DocController.class);
/**
* 批量导入
......@@ -110,15 +85,42 @@ public class DocController extends WebDispatchController {
* @param paramMaps
* @return
*/
private Map<String, String> convertParam(Map<String, String[]> paramMaps) {
private Map<String, Object> convertParam(Map<String, String[]> paramMaps) {
if (MapUtils.isEmpty(paramMaps)) {
return new HashMap<>();
}
Map<String, String> paramMap = new HashMap<>();
Map<String, Object> paramMap = new HashMap<>();
for (Map.Entry<String, String[]> entry : paramMaps.entrySet()) {
paramMap.put(entry.getKey(), entry.getValue()[0]);
String key = entry.getKey();
String value = entry.getValue()[0];
if ("parameter".equals(key)) {
paramMap.put(key, encodeParam(value));
} else {
paramMap.put(key, value);
}
}
return paramMap;
}
/**
* 解码参数
*
* @param parameter
* @return
*/
private Map<String, Object> encodeParam(String parameter) {
try {
if (StringUtils.isBlank(parameter)) {
return null;
}
// 帆软传递进来的参数进行了两次编码,因此需要进行两次解码
String paramsText = URLDecoder.decode(parameter, "UTF-8");
paramsText = URLDecoder.decode(paramsText, "UTF-8");
return JSONObject.parseObject(paramsText).getInnerMap();
} catch (Exception e) {
log.error("字符串解码:{}", e.getMessage(), e);
throw new PlatException("参数格式错误,解码失败");
}
}
}
package com.baosight.hpjx.controller;
import com.baosight.hpjx.core.utils.Iplat4jUtils;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.iplat4j.core.ei.EiConstant;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
* @author:songx
* @date:2024/3/14,14:26
*/
@CrossOrigin
@RestController
@RequestMapping({"/file"})
public class FileController {
/**
* 删除文件
*
* @param docId
* @throws IOException
*/
@RequestMapping(value = "/delete/{docId}", method = RequestMethod.GET)
public Map delete(@PathVariable String docId) throws IOException {
Map resultMap = new HashMap();
try {
Iplat4jUtils.deleteFileByDocId(docId);
resultMap.put("id", docId);
resultMap.put("status", EiConstant.STATUS_SUCCESS);
resultMap.put("message", "SUCCESS");
} catch (Exception e) {
resultMap.put("status", 500);
resultMap.put("message", LogUtils.getMsg(e));
}
return resultMap;
}
}
......@@ -12,7 +12,7 @@ public class CommonConstant {
* @author:songx
* @date:2024/1/20,15:04
*/
public static class projectEnv {
public static class ProjectEnv {
// 开发环境
public static final String DEV = "dev";
......@@ -51,6 +51,20 @@ public class CommonConstant {
// 日
public static final String DAY = "DAY";
}
/**
* 设备计划状态
*
* @author:songx
* @date:2024/1/20,15:04
*/
public static class PlanStatus{
// 审核通过
public static final Integer UN_PLAN = 1;
// 待审核
public static final Integer ON_PLAN = 0;
}
/**
* 常用字段常量
......@@ -62,6 +76,8 @@ public class CommonConstant {
// DETAIL
public static final String DETAIL = "detail";
// DETAIL1
public static final String DETAIL1 = "detail1";
// ID
public static final String ID = "id";
// 生产订单号
......@@ -73,4 +89,20 @@ public class CommonConstant {
// 项目档案ID
public static final String PROJ_ID = "projId";
}
/**
* 环境变量
*
* @author:songx
* @date:2024/1/20,15:04
*/
public static class FileLocation {
// 本地
public static final String LOCAL = "local";
// S3
public static final String S3 = "s3";
}
}
package com.baosight.hpjx.core.constant;
import com.baosight.iplat4j.core.ioc.spring.PlatApplicationContext;
import lombok.Data;
/**
* @author:songx
* @date:2023/8/28,10:05
*/
@Data
public class S3Constant {
/**
* s3、local
*/
public static String FILE_LOCATION = PlatApplicationContext.getProperty("iplat4j.admin.upload.fileLocation");
/**
* endpoint
*/
public static String ENDPOINT = PlatApplicationContext.getProperty("iplat4j.admin.objectStorage.s3.endpoint");
/**
* bucket名称
*/
public static String BUCKET_NAME = PlatApplicationContext.getProperty("iplat4j.admin.objectStorage.s3.bucket");
/**
* AK
*/
public static String ACCESS_KEY = PlatApplicationContext.getProperty("iplat4j.admin.objectStorage.s3.accessKey");
/**
* SK
*/
public static String SECRET_KEY = PlatApplicationContext.getProperty("iplat4j.admin.objectStorage.s3.secretKey");
}
<?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="SqlBase">
<!-- 规格 -->
<sql id="specCondition">
<isNotEmpty prepend=" AND " property="spec">
<isEqual property="spec" compareValue="无规格">
SPEC_ID IN (SELECT ID FROM ${metaSchema}.HGPZ005 WHERE SPEC = '')
</isEqual>
<isNotEqual property="spec" compareValue="无规格">
SPEC_ID IN (SELECT ID FROM ${metaSchema}.HGPZ005 WHERE SPEC = #spec#)
</isNotEqual>
</isNotEmpty>
</sql>
<!-- 创建时间 -->
<sql id="createdTimeCondition">
<isNotEmpty prepend=" AND " property="createdTimeFrom">
CREATED_TIME &gt;= #createdTimeFrom#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdTimeTo">
CREATED_TIME &lt;= #createdTimeTo#
</isNotEmpty>
</sql>
<!-- 权限校验 -->
<sql id="authCondition">
<isNotEmpty prepend=" AND " property="companyCode">
COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="depCode">
DEP_CODE = #depCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="depCodes">
DEP_CODE IN <iterate close=")" open="(" conjunction="," property="depCodes">#depCodes[]#</iterate>
</isNotEmpty>
</sql>
<!-- 公共修改字段 -->
<sql id="updateRevise">
UPDATED_BY = #updatedBy#, <!-- 修改人 -->
UPDATED_NAME = #updatedName#, <!-- 修改人名称 -->
UPDATED_TIME = #updatedTime# <!-- 修改时间 -->
</sql>
</sqlMap>
package com.baosight.hpjx.common;
package com.baosight.hpjx.core.enums;
import com.baosight.hpjx.hp.sc.domain.HPSC002;
import com.baosight.hpjx.hp.sc.domain.HPSC006;
import com.baosight.hpjx.hp.sc.domain.HPSC102;
/**
* @author:songx
......@@ -10,20 +11,51 @@ import com.baosight.hpjx.hp.sc.domain.HPSC006;
*/
public enum DocRouteEnum {
HPSC002("route_001", "HPSC002", "importData", HPSC002.class),
HPSC006("route_002", "HPSC006", "importData",HPSC006 .class);
HPSC002("route_001", "", 1, "HPSC002", "importData", HPSC002.class),
HPSC006("route_002", "", 1, "HPSC006", "importData", HPSC006.class),
HPSC102("route_003", "",1,"HPSC102", "importData", HPSC102.class)
;
/**
* 唯一标识
*/
private String id;
/**
* 模版文件的地址,模版文件路径必须在META-INF.resources下面
*/
private String templateUrl;
/**
* 数据从excel的第几行开始,起始0
*/
private int startRow;
/**
* 业务处理类
*/
private String serviceNme;
/**
* 业务处理方法
*/
private String methodName;
/**
* 数据转换后的实体类
*/
private Class clazz;
<T> DocRouteEnum(String id, String serviceNme, String methodName, Class<T> clazz) {
<T> DocRouteEnum(String id, String templateUrl, int startRow, String serviceNme, String methodName,
Class<T> clazz) {
this.id = id;
this.templateUrl = templateUrl;
this.startRow = startRow;
this.serviceNme = serviceNme;
this.methodName = methodName;
this.clazz = clazz;
}
/**
* 根据ID获取枚举
*
......@@ -38,19 +70,27 @@ public enum DocRouteEnum {
}
return null;
}
public String getId() {
return id;
}
public String getTemplateUrl() {
return templateUrl;
}
public int getStartRow() {
return startRow;
}
public String getServiceNme() {
return serviceNme;
}
public String getMethodName() {
return methodName;
}
public Class getClazz() {
return clazz;
}
......
package com.baosight.hpjx.core.enums;
/**
* @author wwl
* @version 1.0 2024/5/21
*/
public enum HandleStatusEnum {
UNPROCESS(0, "待处理"),
PROCESSING(1, "处理中"),
PROCESSED(2, "已处理");
private Integer code;
private String value;
HandleStatusEnum(Integer code, String value) {
this.code = code;
this.value = value;
}
public static HandleStatusEnum getEnumByCode(Integer code) {
for (HandleStatusEnum en : HandleStatusEnum.values()) {
if (code.compareTo(en.code) == 0) {
return en;
}
}
return null;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
package com.baosight.hpjx.core.interceptor;
import com.baosight.hpjx.core.constant.EPCodeConstant;
import com.baosight.hpjx.core.security.UserSessionUtils;
import com.baosight.hpjx.core.tools.ServletTools;
import com.baosight.hpjx.util.ObjectUtils;
import com.baosight.hpjx.util.StringUtils;
......@@ -31,7 +32,7 @@ public class MyHandlerInterceptor implements HandlerInterceptor {
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception {
try {
// 设置环境变量
request.setAttribute("projectEnv", ProjectInfo.getProjectEnv());
request.setAttribute("PROJECT_ENV", ProjectInfo.getProjectEnv());
// 校验接口权限
boolean isInterfaceAuth = this.checkUserInterfaceAuth(request, response);
if (!isInterfaceAuth) {
......@@ -46,6 +47,8 @@ public class MyHandlerInterceptor implements HandlerInterceptor {
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object o,
ModelAndView modelAndView) throws Exception {
// 设置登录用户的企业编码
request.setAttribute("COMPANY_CODE", UserSessionUtils.getCompanyCode());
}
@Override
......
......@@ -3,6 +3,7 @@ package com.baosight.hpjx.core.tools;
import com.baosight.hpjx.core.dao.DaoBase;
import com.baosight.hpjx.util.AssertUtils;
import com.baosight.iplat4j.common.ed.domain.TEDFA00;
import com.baosight.iplat4j.common.eu.domain.Teudm05;
import com.baosight.iplat4j.core.exception.PlatException;
import org.apache.commons.collections.CollectionUtils;
......@@ -16,7 +17,7 @@ import java.util.Map;
* @author:songx
* @date:2022/8/10,13:55
*/
public class EDTools {
public class Iplat4jTools {
/**
* 页面工具类
......@@ -33,7 +34,7 @@ public class EDTools {
* @return
*/
public static TEDFA00 query(String ename) {
AssertUtils.isNull(ename, "页面英文名称不能为空!");
AssertUtils.isEmpty(ename, "页面英文名称不能为空!");
Map<String, String> paramMap = new HashMap();
paramMap.put("form_ename", ename);
List<TEDFA00> results = DaoBase.getInstance().query("tedfa00.query", paramMap);
......@@ -56,7 +57,7 @@ public class EDTools {
* @return
*/
public static List<Map<String, Object>> list(String codeSetCode) {
AssertUtils.isNull(codeSetCode, "代码分类编码不能为空!");
AssertUtils.isEmpty(codeSetCode, "代码分类编码不能为空!");
Map<String, String> paramMap = new HashMap();
paramMap.put("codesetCode", codeSetCode);
List<Map<String, Object>> results = DaoBase.getInstance().query("EDCM01.queryDetail", paramMap);
......@@ -68,4 +69,26 @@ public class EDTools {
}
/**
* 上传的文件
*
* @author:songx
* @date:2024/8/8,16:47
*/
public static class EuDm05 {
/**
* 查询页面信息
*
* @param docId
* @return
*/
public static Teudm05 getDocByDocId(String docId) {
AssertUtils.isEmpty(docId, "文件ID不能为空!");
Map<String, String> paramMap = new HashMap();
paramMap.put("resId", docId);
List<Teudm05> results = DaoBase.getInstance().query("EUDM05.getDocByDocId", paramMap);
return CollectionUtils.isEmpty(results) ? null : results.get(0);
}
}
}
package com.baosight.hpjx.core.utils;
import com.baosight.hpjx.core.constant.S3Constant;
import com.baosight.hpjx.core.tools.Iplat4jTools;
import com.baosight.hpjx.util.FileUtils;
import com.baosight.hpjx.util.StringUtils;
import com.baosight.iplat4j.common.eu.domain.Teudm05;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.ioc.spring.PlatApplicationContext;
import com.baosight.iplat4j.eu.dm.util.PlatFileUploader;
import java.util.Map;
/**
* @author:songx
* @date:2024/8/8,17:00
*/
public class Iplat4jUtils {
static PlatFileUploader platFileUploader = PlatApplicationContext.getApplicationContext()
.getBean("platFileUploader", PlatFileUploader.class);
/**
* 删除文件
*
* @param docId
* @return
*/
public static boolean deleteFileByDocId(String docId) {
// 判断文件上传的地址
String fileLocation = S3Constant.FILE_LOCATION;
if ("s3".equalsIgnoreCase(fileLocation)) {
Teudm05 dbDm05 = Iplat4jTools.EuDm05.getDocByDocId(docId);
if (dbDm05 == null) {
throw new PlatException("文件在服务器中不存在");
}
// 从文件路径中截取key,不包含域名和bucket名称
String url = dbDm05.getUrl();
if (StringUtils.isBlank(url)) {
return false;
}
// 删除本地记录
// platFileUploader.deleteDocById(docId);
// 删除S3文件
String key = url.replace(S3Constant.ENDPOINT + "/", "");
return S3Utils.deleteFile(key);
} else {
Map document = platFileUploader.getDocument(docId);
String chgName = document.get("chgName").toString();
String docPath = document.get("realPath").toString();
String filePath = docPath + chgName;
// if (platFileUploader.deleteDocById(docId) > 0) {
return FileUtils.deleteFile(filePath);
// }
// return false;
}
}
}
package com.baosight.hpjx.core.utils;
import com.amazonaws.ClientConfiguration;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.client.builder.AwsClientBuilder;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.baosight.hpjx.core.constant.S3Constant;
import lombok.extern.slf4j.Slf4j;
/**
* OSS凭证
*
* @author:songx
* @date:2023/8/28,11:26
*/
@Slf4j
public class S3ClientUtils {
private S3ClientUtils() {
}
/**
* 初始化配置信息(纯粹就打印日志而已,因为会加载该类的全局变量)
*/
public static void init() {
AmazonS3 s3Client = Instance.s3Client;
log.info("初始化OSS客户端完成:isReady -> {}", s3Client != null);
}
/**
* 获取S3客户端
*
* @return
*/
public static AmazonS3 getS3Client() {
return Instance.s3Client;
}
/**
* 刷新客户端
*/
public static void refresh() {
Instance.refresh();
}
/**
* 初始化Instance
*
* @author:songx
* @date:2022/4/2,9:58
*/
private static class Instance {
/**
* 客户端实例
*/
private static AmazonS3 s3Client = buildAmazonS3();
/**
* 刷新S3客户端
*/
private static void refresh() {
s3Client = buildAmazonS3();
log.info("刷新OSS客户端完成:isReady->{}", s3Client != null);
}
/**
* 获取AmazonS3Client实例
*
* @return
*/
private static synchronized AmazonS3 buildAmazonS3() {
if (!"s3".equalsIgnoreCase(S3Constant.FILE_LOCATION)) {
return null;
}
// 判断上传类型是否S3
AmazonS3ClientBuilder client = AmazonS3ClientBuilder.standard();
ClientConfiguration config = new ClientConfiguration();
config.setProtocol(com.amazonaws.Protocol.HTTPS);
config.setConnectionTimeout(10001);
config.setSignerOverride("S3SignerType");
client.setClientConfiguration(config);
client.setCredentials(new AWSStaticCredentialsProvider(
new BasicAWSCredentials(S3Constant.ACCESS_KEY, S3Constant.SECRET_KEY)));
// 去掉地址中的bucket前缀
String endpoint = S3Constant.ENDPOINT.replace(S3Constant.BUCKET_NAME + ".", "");
client.setEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, null));
return client.build();
}
}
}
package com.baosight.hpjx.core.utils;
import com.amazonaws.services.s3.AmazonS3;
import com.baosight.hpjx.core.constant.S3Constant;
import com.baosight.hpjx.util.AssertUtils;
import java.io.File;
/**
* OSS工具类
*
* @author:songx
* @date:2023/8/28,11:25
*/
public class S3Utils {
/**
* 上传文件
*
* @param key 默认不指定key的情况下,以文件内容的hash值作为文件名
* @param file
*/
public static void uploadFile(String key, File file) {
AmazonS3 client = S3ClientUtils.getS3Client();
AssertUtils.isNull(client, "上传失败,OSS客户端未初始化,请检查");
client.putObject(S3Constant.BUCKET_NAME, key, file);
}
/**
* 删除文件
*
* @param key
*/
public static boolean deleteFile(String key) {
AmazonS3 client = S3ClientUtils.getS3Client();
AssertUtils.isNull(client, "删除失败,OSS客户端未初始化,请检查");
client.deleteObject(S3Constant.BUCKET_NAME, key);
return true;
}
}
......@@ -72,6 +72,23 @@ public class HPConstant {
public static final String PRO_PLAN_NO = "PRO_PLAN_NO";
//采购订单单号
public static final String PRO_ORDER_NO = "PRO_ORDER_NO";
public static final String HGSC008_WORK_CODE = "WORK_CODE";
//计划单号
public static final String PLAN_CODE = "PLAN_CODE";
//记录单号
public static final String RECORD_CODE = "RECORD_CODE";
//维修申请单号
public static final String APPLY_CODE = "APPLY_CODE";
//设备点检单号
public static final String INSPEC_CODE = "INSPEC_CODE";
//设备保养单号
public static final String UPKEEP_CODE = "UPKEEP_CODE";
// 整改通知单号
public static final String RECTIFY_ID = "RECTIFY_ID";
//收款单
public static final String CW_COLLECTION_NO = "CW_COLLECTION_NO";
}
/**
......
package com.baosight.hpjx.hp.constant;
import com.jcraft.jsch.UserAuth;
/**
* @author:songx
* @date:2024/1/18,17:16
......@@ -352,6 +350,8 @@ public class HPSqlConstant {
public static final String LOCK = "HPSC005.lock";
// 查询
public static final String UPDATE_ASSIGN_NUM = "HPSC005.updateAssignNum";
// 修改完成重量
public static final String UPDATE_ASSIGN_WT = "HPSC005.updateAssignWt";
public static final String DELETE_BY_MAT = "HPSC005.deleteByMat";
......@@ -387,11 +387,24 @@ public class HPSqlConstant {
// 已处理
public static final String DO_PROCESS = "HPZL001.doProcess";
// 已处理
public static final String DO_PROCESS2 = "HPZL001.doProcess2";
}
/**
* @author:songx
* @date:2024/8/13,10:24
*/
public class HpZl004 {
// 锁
public static final String LOCK = "HPZL004.lock";
// 确认
public static final String CONFIRM = "HPZL004.confirm";
}
/**
* HPXSOrg SQL 定义
*
......
package com.baosight.hpjx.hp.dm.constant;
/**
* @author:songx
* @date:2024/8/13,16:43
*/
public class HpDmConstant {
/**
* 业务类型
*
* @author:songx
* @date:2024/8/13,16:43
*/
public static class BizType {
// 整改通知单-处理照片
public static final String RECTIFY_HANDLE = "RECTIFY_HANDLE";
// 整改通知单-问题照片
public static final String RECTIFY_DEFECT = "RECTIFY_DEFECT";
}
}
package com.baosight.hpjx.hp.dm.service;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.constant.S3Constant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.core.utils.Iplat4jUtils;
import com.baosight.hpjx.hp.dm.domain.HPDM099;
import com.baosight.hpjx.hp.xs.domain.HPXS007A;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.MapUtils;
import com.baosight.iplat4j.core.ProjectInfo;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import java.util.List;
import java.util.Map;
/**
* 附件清单
*
* @author:songx
* @date:2024/8/13,15:27
*/
public class ServiceHPDM099 extends ServiceEPBase {
/**
* 画面初始化
*
* @param inInfo
* @return
*/
public EiInfo initLoad(EiInfo inInfo) {
try {
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HPDM099().eiMetadata);
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
/**
* 查询操作
*
* @param inInfo
* @return
*/
@Override
public EiInfo query(EiInfo inInfo) {
try {
// 文件存储位置
if (CommonConstant.FileLocation.S3.equalsIgnoreCase(S3Constant.FILE_LOCATION)) {
inInfo = super.query(inInfo, "HPDM099.queryS3", new HPDM099());
} else {
inInfo = super.query(inInfo, "HPDM099.queryLocal", new HPDM099());
}
} catch (Throwable e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
return inInfo;
}
/**
* 新增操作
*
* @param inInfo
* @return
*/
public EiInfo upload(EiInfo inInfo) {
try {
HPDM099 fDm099 = MapUtils.toDaoEPBase(inInfo, HPDM099.class);
fDm099.setDeleteFlag(CommonConstant.YesNo.NO_0);
DaoUtils.insert(HPDM099.INSERT, fDm099);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("上传成功");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "新增失败");
}
return inInfo;
}
/**
* 删除操作
*
* @param inInfo
* @return
*/
public EiInfo delete(EiInfo inInfo) {
try {
List<HPDM099> fDm099s = MapUtils.toDaoEPBases(inInfo, HPDM099.class);
for (HPDM099 fDm099 : fDm099s) {
DaoUtils.update(HPDM099.DELETE, fDm099);
if (!fDm099.getDocId().isEmpty()) {
Iplat4jUtils.deleteFileByDocId(fDm099.getDocId());
}
}
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + fDm099s.size() + "]条数据删除成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "删除失败");
}
return inInfo;
}
}
package com.baosight.hpjx.hp.dm.service;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
/**
* 附件上传
*
* @author:songx
* @date:2024/8/13,15:26
*/
public class ServiceHPDM099A extends ServiceBase {
/**
* 画面初始化.
*/
public EiInfo initLoad(EiInfo inInfo) {
return inInfo;
}
/**
* 附件上传.
*/
public EiInfo form(EiInfo inInfo) {
return inInfo;
}
}
package com.baosight.hpjx.hp.dm.service;
import com.baosight.hpjx.core.enums.DocRouteEnum;
import com.baosight.hpjx.util.EiInfoUtils;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
import java.util.Map;
/**
* 文件导入
*
* @author:songx
* @date:2024/4/7,17:02
*/
public class ServiceHPDM91 extends ServiceEPBase {
/**
* 初始化
*
* @param inInfo
* @return
*/
@Override
public EiInfo initLoad(EiInfo inInfo) {
try {
Map queryRow = EiInfoUtils.getFirstRow(inInfo);
setTemplateUrl(queryRow);
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
/**
* 根据路由获取模版地址
*
* @param queryRow
* @return
*/
private void setTemplateUrl(Map queryRow) {
String templateUrl = "";
String id = MapUtils.getString(queryRow, "id");
if (StringUtils.isNotBlank(id)) {
DocRouteEnum docRouteEnum = DocRouteEnum.getById(id);
templateUrl = docRouteEnum == null ? "" : docRouteEnum.getTemplateUrl();
}
queryRow.put("templateUrl", templateUrl);
}
}
<?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="HPDM099">
<sql id="column">
A.ID as "id",
A.COMPANY_CODE as "companyCode", <!-- 企业编码 预留 -->
A.DEP_CODE as "depCode", <!-- 部门编码 预留 -->
A.CREATED_BY as "createdBy", <!-- 创建人 -->
A.CREATED_NAME as "createdName", <!-- 创建人名称 -->
A.CREATED_TIME as "createdTime", <!-- 创建时间 -->
A.UPDATED_BY as "updatedBy", <!-- 修改人 -->
A.UPDATED_NAME as "updatedName", <!-- 修改人名称 -->
A.UPDATED_TIME as "updatedTime", <!-- 修改时间 -->
A.BIZ_TYPE as "bizType", <!-- 业务类型 -->
A.BIZ_ID as "bizId", <!-- 业务ID -->
A.DOC_ID as "docId" <!-- 文件ID -->
</sql>
<sql id="columnLocal">
<include refid="column"/>,
B.DOC_NAME as "docName" <!-- 文件名称 -->
</sql>
<sql id="columnS3">
<include refid="column"/>,
B.RES_CNAME as "docName" <!-- 文件名称 -->
</sql>
<sql id="condition">
AND A.DELETE_FLAG = '0'
<include refid="SqlBase.authCondition"/>
<isNotEmpty prepend=" AND " property="id">
A.ID = #id#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="bizType">
A.BIZ_TYPE = #bizType#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="bizId">
A.BIZ_ID = #bizId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="docId">
A.DOC_ID = #docId#
</isNotEmpty>
</sql>
<sql id="customCondition">
<include refid="condition"/>
<isNotEmpty prepend=" AND " property="createdDateFrom">
A.CREATED_TIME &gt;= CONCAT(REPLACE(#createdDateFrom#, '-', ''), '000000')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdDateTo">
A.CREATED_TIME &lt;= CONCAT(REPLACE(#createdDateTo#, '-', ''), '235959')
</isNotEmpty>
</sql>
<!-- 本地 -->
<sql id="conditionLocal">
AND A.DOC_ID = B.DOC_ID
<include refid="customCondition"/>
<isNotEmpty prepend=" AND " property="docName">
B.DOC_NAME LIKE CONCAT('%', #docName#, '%')
</isNotEmpty>
</sql>
<!-- S3地址 -->
<sql id="conditionS3">
AND A.DOC_ID = B.RES_ID
<include refid="customCondition"/>
<isNotEmpty prepend=" AND " property="docName">
B.RES_CNAME LIKE CONCAT('%', #docName#, '%')
</isNotEmpty>
</sql>
<sql id="orderBy">
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
$orderBy$
</isNotEmpty>
<isEmpty property="orderBy">
A.ID asc
</isEmpty>
</dynamic>
</sql>
<select id="queryLocal" resultClass="com.baosight.hpjx.hp.dm.domain.HPDM099">
SELECT
<include refid="columnLocal"/>
FROM ${hpjxSchema}.T_HPDM099 A, ${platSchema}.TEUDM02 B
WHERE 1=1
<include refid="conditionLocal"/>
<include refid="orderBy"/>
</select>
<select id="countLocal" resultClass="int">
SELECT COUNT(*)
FROM ${hpjxSchema}.T_HPDM099 A, ${platSchema}.TEUDM02 B
WHERE 1=1
<include refid="conditionLocal"/>
</select>
<select id="queryS3" resultClass="com.baosight.hpjx.hp.dm.domain.HPDM099">
SELECT
<include refid="columnS3"/>
FROM ${hpjxSchema}.T_HPDM099 A, ${platSchema}.TEUDM05 B
WHERE 1=1
<include refid="conditionS3"/>
<include refid="orderBy"/>
</select>
<select id="countS3" resultClass="int">
SELECT COUNT(*)
FROM ${hpjxSchema}.T_HPDM099 A, ${platSchema}.TEUDM05 B
WHERE 1=1
<include refid="conditionS3"/>
</select>
<insert id="insert">
INSERT INTO ${hpjxSchema}.T_HPDM099 (
COMPANY_CODE, <!-- 企业编码 预留 -->
DEP_CODE, <!-- 部门编码 -->
CREATED_BY, <!-- 创建人 -->
CREATED_NAME, <!-- 创建人名称 -->
CREATED_TIME, <!-- 创建时间 -->
DELETE_FLAG, <!-- 是否删除 -->
BIZ_TYPE, <!-- 业务类型 -->
BIZ_ID, <!-- 业务ID -->
DOC_ID <!-- 文件ID -->
) VALUES (
#companyCode#, #depCode#, #createdBy#, #createdName#, #createdTime#,
#deleteFlag#, #bizType#, #bizId#, #docId#
)
</insert>
<delete id="delete">
UPDATE ${hpjxSchema}.T_HPDM099
SET DELETE_FLAG = '1'
WHERE ID = #id#
</delete>
</sqlMap>
package com.baosight.hpjx.hp.dm.tools;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.constant.S3Constant;
import com.baosight.hpjx.core.dao.DaoBase;
import com.baosight.hpjx.hp.dm.domain.HPDM099;
import com.baosight.hpjx.hp.xs.domain.HPXS007A;
import com.baosight.hpjx.hp.zl.domain.HPZL004;
import com.baosight.hpjx.util.AssertUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author:songx
* @date:2024/8/13,16:40
*/
public class HpDmTools {
/**
* @author:songx
* @date:2024/8/13,16:40
*/
public static class HpDm099 {
/**
* 查询
*
* @param bizType
* @param bizId
* @return
*/
public static List<HPDM099> list(String bizType, String bizId) {
AssertUtils.isEmpty(bizId, "业务ID不能为空");
Map<String, Object> paramMap = new HashMap();
paramMap.put(HPDM099.FIELD_BIZ_TYPE, bizType);
paramMap.put(HPDM099.FIELD_BIZ_ID, bizId);
if (CommonConstant.FileLocation.S3.equalsIgnoreCase(S3Constant.FILE_LOCATION)) {
return DaoBase.getInstance().query("HPDM099.queryS3", paramMap);
} else {
return DaoBase.getInstance().query("HPDM099.queryLocal", paramMap);
}
}
}
}
......@@ -189,8 +189,8 @@ public class HPKC003 extends DaoEPBase {
eiColumn = new EiColumn(FIELD_WEIGHT);
eiColumn.setType("N");
eiColumn.setScaleLength(0);
eiColumn.setFieldLength(12);
eiColumn.setScaleLength(3);
eiColumn.setFieldLength(20);
eiColumn.setDescName("重量");
eiMetadata.addMeta(eiColumn);
......
......@@ -42,6 +42,8 @@ public class HPKC004 extends DaoEPBase {
public static final String FIELD_AMOUNT = "amount"; /* 数量*/
public static final String FIELD_UNIT_WEIGHT = "unitWeight"; /* 单重*/
public static final String FIELD_WEIGHT = "weight"; /* 重量*/
public static final String FIELD_INV_WEIGHT = "invWeight"; /* 库存重量*/
public static final String FIELD_DIFF_WEIGHT = "diffWeight"; /* 差异重量*/
public static final String FIELD_REMARK = "remark"; /* 备注*/
public static final String FIELD_KC_ID = "kcId"; /* 库存ID*/
public static final String FIELD_OLD_SALE_NO = "oldSaleNo"; /* 原销售单号*/
......@@ -58,7 +60,6 @@ public class HPKC004 extends DaoEPBase {
public static final String FIELD_FACTORY_CODE = "factoryCode"; /* 厂区编码*/
public static final String FIELD_FACTORY_NAME = "factoryName"; /* 工厂*/
public static final String COL_ID = "ID"; /* ID*/
public static final String COL_COMPANY_CODE = "COMPANY_CODE"; /* 企业编码 预留*/
public static final String COL_DEP_CODE = "DEP_CODE"; /* 部门编码 预留*/
......@@ -79,6 +80,8 @@ public class HPKC004 extends DaoEPBase {
public static final String COL_AMOUNT = "AMOUNT"; /* 数量*/
public static final String COL_UNIT_WEIGHT = "UNIT_WEIGHT"; /* 单重*/
public static final String COL_WEIGHT = "WEIGHT"; /* 重量*/
public static final String COL_INV_WEIGHT = "INV_WEIGHT"; /* 库存重量*/
public static final String COL_DIFF_WEIGHT = "DIFF_WEIGHT"; /* 差异重量*/
public static final String COL_REMARK = "REMARK"; /* 备注*/
public static final String COL_KC_ID = "KC_ID"; /* 库存ID*/
public static final String COL_OLD_SALE_NO = "OLD_SALE_NO"; /* 原销售单号*/
......@@ -121,6 +124,8 @@ public class HPKC004 extends DaoEPBase {
private BigDecimal amount = new BigDecimal(0.000); /* 数量*/
private BigDecimal unitWeight = new BigDecimal(0.000); /* 单重*/
private BigDecimal weight = new BigDecimal(0.000); /* 重量*/
private BigDecimal invWeight = new BigDecimal(0.000); /* 库存重量*/
private BigDecimal diffWeight = new BigDecimal(0.000); /* 差异重量*/
private String remark = " "; /* 备注*/
private Long kcId; /* 库存ID*/
private String oldSaleNo = " "; /* 原销售单号*/
......@@ -241,7 +246,21 @@ public class HPKC004 extends DaoEPBase {
eiColumn.setFieldLength(15);
eiColumn.setDescName("重量");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_INV_WEIGHT);
eiColumn.setType("N");
eiColumn.setScaleLength(3);
eiColumn.setFieldLength(15);
eiColumn.setDescName("库存重量");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_DIFF_WEIGHT);
eiColumn.setType("N");
eiColumn.setScaleLength(3);
eiColumn.setFieldLength(15);
eiColumn.setDescName("差异重量");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_REMARK);
eiColumn.setDescName("备注");
eiMetadata.addMeta(eiColumn);
......@@ -631,6 +650,38 @@ public class HPKC004 extends DaoEPBase {
this.weight = weight;
}
/**
* get the invWeight - 库存重量.
* @return the invWeight
*/
public BigDecimal getInvWeight() {
return this.invWeight;
}
/**
* set the invWeight - 库存重量.
*
* @param invWeight - 库存重量
*/
public void setInvWeight(BigDecimal invWeight) {
this.invWeight = invWeight;
}
/**
* get the diffWeight - 差异重量.
* @return the diffWeight
*/
public BigDecimal getDiffWeight() {
return this.diffWeight;
}
/**
* set the diffWeight - 差异重量.
*
* @param diffWeight - 差异重量
*/
public void setDiffWeight(BigDecimal diffWeight) {
this.diffWeight = diffWeight;
}
/**
* get the remark - 备注.
* @return the remark
*/
......@@ -891,6 +942,8 @@ public class HPKC004 extends DaoEPBase {
setAmount(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_AMOUNT)), amount));
setUnitWeight(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_UNIT_WEIGHT)), unitWeight));
setWeight(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_WEIGHT)), weight));
setInvWeight(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_INV_WEIGHT)), invWeight));
setDiffWeight(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_DIFF_WEIGHT)), diffWeight));
setRemark(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_REMARK)), remark));
setKcId(NumberUtils.toLong(StringUtils.toString(map.get(FIELD_KC_ID)), kcId));
setOldSaleNo(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_OLD_SALE_NO)), oldSaleNo));
......@@ -935,6 +988,8 @@ public class HPKC004 extends DaoEPBase {
map.put(FIELD_AMOUNT, StringUtils.toString(amount, eiMetadata.getMeta(FIELD_AMOUNT)));
map.put(FIELD_UNIT_WEIGHT, StringUtils.toString(unitWeight, eiMetadata.getMeta(FIELD_UNIT_WEIGHT)));
map.put(FIELD_WEIGHT, StringUtils.toString(weight, eiMetadata.getMeta(FIELD_WEIGHT)));
map.put(FIELD_INV_WEIGHT, StringUtils.toString(invWeight, eiMetadata.getMeta(FIELD_INV_WEIGHT)));
map.put(FIELD_DIFF_WEIGHT, StringUtils.toString(diffWeight, eiMetadata.getMeta(FIELD_DIFF_WEIGHT)));
map.put(FIELD_REMARK, StringUtils.toString(remark, eiMetadata.getMeta(FIELD_REMARK)));
map.put(FIELD_KC_ID, StringUtils.toString(kcId, eiMetadata.getMeta(FIELD_KC_ID)));
map.put(FIELD_OLD_SALE_NO, StringUtils.toString(oldSaleNo, eiMetadata.getMeta(FIELD_OLD_SALE_NO)));
......
......@@ -222,8 +222,8 @@ public class HPKC011 extends DaoEPBase {
eiColumn = new EiColumn(FIELD_WEIGHT);
eiColumn.setType("N");
eiColumn.setScaleLength(2);
eiColumn.setFieldLength(10);
eiColumn.setScaleLength(3);
eiColumn.setFieldLength(20);
eiColumn.setDescName("重量");
eiMetadata.addMeta(eiColumn);
......
......@@ -209,8 +209,8 @@ public class HPKC011A extends DaoEPBase {
eiColumn = new EiColumn(FIELD_WEIGHT);
eiColumn.setType("N");
eiColumn.setScaleLength(2);
eiColumn.setFieldLength(10);
eiColumn.setScaleLength(3);
eiColumn.setFieldLength(20);
eiColumn.setDescName("重量");
eiMetadata.addMeta(eiColumn);
......
......@@ -131,7 +131,6 @@ public class ServiceHPKC004 extends ServiceBase {
HPKCTools.updateProdStock(dbKc004.getWhCode(), dbKc004.getProdNo(),
dbKc004.getAmount(), dbKc004.getWeight(),hpkc011.getFactoryCode());
}
}
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
......
......@@ -21,6 +21,7 @@ import com.baosight.iplat4j.core.service.soa.XLocalManager;
import com.baosight.iplat4j.core.util.DateUtils;
import com.baosight.iplat4j.core.web.threadlocal.UserSession;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.lang.StringUtils;
import java.math.BigDecimal;
......@@ -104,31 +105,34 @@ public class ServiceHPKC011 extends ServiceBase {
String factoryCode = inInfo.getString("factoryCode");
BigDecimal amount = new BigDecimal(inInfo.getString("amount"));
BigDecimal weight = new BigDecimal(inInfo.getString("weight"));
boolean isOnlyWeight = BooleanUtils.toBoolean(inInfo.getString("isOnlyWeight"));
String companyCode = UserSessionUtils.getCompanyCode();
try {
checkUpdateStockParam(companyCode,whCode,prodNo,amount,weight);
HPKC011 newObj = generatorBaseInfo(companyCode,whCode,prodNo,amount,weight);
List<Map> list = dao.query("HPKC011.queryByCondition",new HashMap<String,Object>(){{
put("companyCode",companyCode);
put("whCode",whCode);
put("prodNo",prodNo);
checkUpdateStockParam(companyCode, whCode, prodNo, amount, weight);
HPKC011 newObj = generatorBaseInfo(companyCode, whCode, prodNo, amount, weight);
List<Map> list = dao.query("HPKC011.queryByCondition", new HashMap<String, Object>() {{
put("companyCode", companyCode);
put("whCode", whCode);
put("prodNo", prodNo);
}});
if(CollectionUtils.isEmpty(list)){
//新增
if(amount.compareTo(BigDecimal.ZERO)<0
||weight.compareTo(BigDecimal.ZERO)<0){
if (CollectionUtils.isEmpty(list)) {
// 新增
if (amount.compareTo(BigDecimal.ZERO) < 0
|| weight.compareTo(BigDecimal.ZERO) < 0) {
throw new PlatException("当前库存为空,库存变更数量与重量不能小于等于0!");
}
newObj.setFactoryCode(factoryCode);
generatorBaseInfo(newObj);
DaoUtils.insert("HPKC011.insert",newObj);
}else{
//修改
DaoUtils.insert("HPKC011.insert", newObj);
} else {
// 修改
HPKC011 oldObj = new HPKC011();
oldObj.fromMap(list.get(0));
BigDecimal afterAmout = oldObj.getAmount().add(amount);
BigDecimal afterWeight = oldObj.getWeight().add(weight);
if(afterAmout.compareTo(BigDecimal.ZERO)<0||afterWeight.compareTo(BigDecimal.ZERO)<0){
// 仅有重量的时候,不校验数据和重量
if (!isOnlyWeight && (afterAmout.compareTo(BigDecimal.ZERO) < 0
|| afterWeight.compareTo(BigDecimal.ZERO) < 0)) {
throw new PlatException("库存更新失败,出库数量与重量不能大于当前库存!");
}
oldObj.setAmount(afterAmout);
......@@ -136,8 +140,8 @@ public class ServiceHPKC011 extends ServiceBase {
oldObj.setUpdatedBy(newObj.getUpdatedBy());
oldObj.setUpdatedName(newObj.getUpdatedName());
oldObj.setUpdatedTime(newObj.getUpdatedTime());
int result = DaoUtils.update("HPKC011.updateStock",oldObj);
if(result!=1){
int result = DaoUtils.update("HPKC011.updateStock", oldObj);
if (result != 1) {
throw new PlatException("库存更新失败,库存已发生变更或系统异常,请重试!");
}
}
......@@ -158,7 +162,8 @@ public class ServiceHPKC011 extends ServiceBase {
* @param weight
* @reutrn HPKC011
*/
private HPKC011 generatorBaseInfo(String companyCode, String whCode, String prodNo, BigDecimal amout, BigDecimal weight) {
private HPKC011 generatorBaseInfo(String companyCode, String whCode, String prodNo, BigDecimal amout,
BigDecimal weight) {
HPKC011 hpkc011 = new HPKC011();
hpkc011.setCompanyCode(companyCode);
hpkc011.setWhCode(whCode);
......@@ -176,7 +181,7 @@ public class ServiceHPKC011 extends ServiceBase {
hpkc011.setUpdatedTime(time);
return hpkc011;
}
private void generatorBaseInfo(HPKC011 hpkc011) {
EiInfo inInfo = new EiInfo();
try {
......@@ -186,7 +191,7 @@ public class ServiceHPKC011 extends ServiceBase {
EiInfo outInfo = XLocalManager.call(inInfo);
List<HPPZ007> whNameList = (List) outInfo.get("list");
hpkc011.setWhName(whNameList.get(0).getWhName());
}catch (Exception e){
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "库存更新失败!");
throw new PlatException("仓库编码异常,找不到对应的仓库档案!");
}
......@@ -204,40 +209,40 @@ public class ServiceHPKC011 extends ServiceBase {
hpkc011.setPrdtSpec(hpsc005.getPrdtSpec());
hpkc011.setUnitWeight(hpsc005.getUnitWt());
hpkc011.setRemark(hpsc005.getRemark1());
}catch (Exception e){
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "库存更新失败!");
throw new PlatException("生产单号异常,找不到对应的生产订单!");
}
hpkc011.setVersion(new Integer(1));
}
/**
* 校验库存变更请求参数
*
* @param companyCode
* @param whCode
* @param prodNo
* @param amout
* @param weight
*/
private void checkUpdateStockParam(String companyCode, String whCode, String prodNo
, BigDecimal amout, BigDecimal weight){
if(StringUtils.isBlank(companyCode)){
private void checkUpdateStockParam(String companyCode, String whCode, String prodNo, BigDecimal amout,
BigDecimal weight) {
if (StringUtils.isBlank(companyCode)) {
throw new PlatException("企业编码不能为空!");
}
if(StringUtils.isBlank(whCode)){
if (StringUtils.isBlank(whCode)) {
throw new PlatException("仓库编码不能为空!");
}
if(StringUtils.isBlank(prodNo)){
if (StringUtils.isBlank(prodNo)) {
throw new PlatException("生产单号不能为空!");
}
if(Objects.isNull(amout)||
Objects.isNull(amout)){
if (Objects.isNull(amout) || Objects.isNull(weight)) {
throw new PlatException("库存变更数量或重量不能为空!");
}
if(amout.compareTo(BigDecimal.ZERO)==0
&&weight.compareTo(BigDecimal.ZERO)==0){
throw new PlatException("库存变更数量或重量不能为0)!");
// 宏建路桥没有数量的概念,因此这里不校验数量
if (weight.compareTo(BigDecimal.ZERO) == 0) {
throw new PlatException("库存变更数量或重量不能为0!");
}
}
......
package com.baosight.hpjx.hp.kc.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.kc.domain.HPKC003;
import com.baosight.hpjx.hp.kc.tools.HPKCTools;
import com.baosight.hpjx.hp.sc.tools.HPSCTools;
import com.baosight.hpjx.util.BeanUtils;
import com.baosight.hpjx.util.CommonMethod;
import com.baosight.hpjx.util.EiInfoUtils;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.ObjectUtils;
import com.baosight.hpjx.util.StringUtil;
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 java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author:songx
* @date:2024/1/22,10:48
*/
public class ServiceHPKC103 extends ServiceBase {
/**
* 画面初始化
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "生产入库单",operType = "查询",operDesc = "初始化")
public EiInfo initLoad(EiInfo inInfo) {
try {
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.WH_RECORD_BLOCK_ID), new HashMap<String,Object>(){{put("inventTypes",new String[]{"3"});}}, false);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.INVENT_NAME_BLOCK_ID), null);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.FACTORY_RECORD_BLOCK_ID), null, false);
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HPKC003().eiMetadata);
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
inInfo.setStatus(500);
}
return inInfo;
}
/**
* 查询操作
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "生产入库单",operType = "查询",operDesc = "查询")
@Override
public EiInfo query(EiInfo inInfo) {
try {
Map queryRow = EiInfoUtils.getFirstRow(inInfo);
String receiptDate = MapUtils.getString(queryRow, "documentDate");
queryRow.put("documentDate", StringUtil.removeSpecifiedCharacter(receiptDate,
StringUtil.DEFAULT_CHARACTER_TO_BE_REMOVED));
inInfo = super.query(inInfo, "HPKC003.query", new HPKC003());
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
inInfo.setStatus(500);
}
return inInfo;
}
/**
* 删除操作
*
* @param eiInfo
* @return
*/
@OperationLogAnnotation(operModul = "生产入库单",operType = "删除",operDesc = "删除")
public EiInfo delete(EiInfo eiInfo) {
try {
List<Map> resultRows = eiInfo.getBlock(EiConstant.resultBlock).getRows();
List<String> prodNos = ObjectUtils.listKey(resultRows, "prodNo");
List<String> prodOrderNos = ObjectUtils.listKey(resultRows, "prodOrderNo");
// 锁库存
HPKCTools.HpKc003.lock(prodNos);
// 锁生产计划明细
HPSCTools.HpSc004.lock(prodOrderNos);
// 查询数据
Map<String, HPKC003> dbKc003Map = HPKCTools.HpKc003.map(prodNos);
for (Map resultRow : resultRows) {
HPKC003 fKc003 = new HPKC003();
fKc003.fromMap(resultRow);
DaoUtils.update(HPKC003.DELETE, fKc003);
// 生产一条负数量和产量的红冲记录
HPKC003 dbKc003 = dbKc003Map.get(fKc003.getProdNo());
HPKC003 newKc003 = BeanUtils.copy(dbKc003, HPKC003.class);
newKc003.setAmount(dbKc003.getAmount().negate());
newKc003.setWeight(dbKc003.getWeight().negate());
newKc003.setDeleteFlag(1);
newKc003.setProdNoOld(fKc003.getProdNo());
newKc003.setProdNo(SequenceGenerator.getNextSequence(HPConstant.SequenceId.HPKC003_PROD_NO));
DaoUtils.insert(HPKC003.INSERT, newKc003);
// 同步生产计划
HPSCTools.syncPlan(newKc003.getProdOrderNo(), newKc003.getAmount());
// 更新生产任务已完成数量
HPSCTools.HpSc005a.updateCompleteNum(newKc003.getProdTaskNo(), newKc003.getAmount());
// 修改库存
HPKCTools.updateProdStock(newKc003.getWhCode(), newKc003.getProdOrderNo(),
BigDecimal.ZERO, newKc003.getWeight(), newKc003.getFactoryCode(), true);
}
eiInfo.setStatus(EiConstant.STATUS_SUCCESS);
eiInfo.setMsg("删除成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(eiInfo, e, "删除失败");
eiInfo.setStatus(500);
}
return eiInfo;
}
}
package com.baosight.hpjx.hp.kc.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.common.InventTypeEnum;
import com.baosight.hpjx.common.ProdOrderStatusEnum;
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.kc.domain.HPKC003;
import com.baosight.hpjx.hp.kc.tools.HPKCTools;
import com.baosight.hpjx.hp.pz.tools.HPPZTools;
import com.baosight.hpjx.hp.sc.domain.HPSC005B;
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.CommonMethod;
import com.baosight.hpjx.util.DateUtils;
import com.baosight.hpjx.util.EiInfoUtils;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.MapUtils;
import com.baosight.hpjx.util.ObjectUtils;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 选择生产任务
*
* @author:songx
* @date:2022/7/11,11:08
*/
public class ServiceHPKC103A extends ServiceEPBase {
private final Integer[] DEFAULT_INVENT_TYPE = {InventTypeEnum.SEMI_FINISHED_PRODUCT.getCode()};
/**
* 初始化
*
* @param inInfo
* @return
*/
@Override
@OperationLogAnnotation(operModul = "生产任务查询", operType = "查询", operDesc = "生产入库单-生产任务查询-初始化")
public EiInfo initLoad(EiInfo inInfo) {
try {
Map queryMap = new HashMap();
//"2",
queryMap.put("inventTypes", new String[]{"3"});
queryMap.put("userId", UserSessionUtils.getUserId());
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.USER_GROUP_BLOCK_ID), queryMap, false);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.WH_RECORD_BLOCK_ID), queryMap, false);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.FACTORY_RECORD_BLOCK_ID), null, false);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.GROUP_RECORD_BLOCK_ID), null, false);
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HPSC005B().eiMetadata);
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
inInfo.setStatus(500);
}
return inInfo;
}
/**
* 查询数据列表
*
* @param inInfo
* @return
*/
@Override
@OperationLogAnnotation(operModul = "生产任务查询", operType = "查询", operDesc = "生产入库单-生产任务查询-查询")
public EiInfo query(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
queryMap.put("isComplete", CommonConstant.YesNo.NO_0);
inInfo = super.query(inInfo, HPSC005B.QUERY, new HPSC005B());
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
inInfo.setStatus(500);
}
return inInfo;
}
/**
* 生成入库单(小程序)
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "生产任务查询", operType = "插入", operDesc = "生产入库单-生产任务查询-生成入库单")
public EiInfo select(EiInfo inInfo) {
inInfo = selectDo(inInfo);
if (inInfo.getStatus() == EiConstant.STATUS_FAILURE) {
inInfo.setStatus(500);
}
return inInfo;
}
/**
* 生成入库单
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "生产任务查询", operType = "插入", operDesc = "生产入库单-生产任务查询-生成入库单")
public EiInfo selectDo(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 订单号
List<String> prodOrderNos = ObjectUtils.listKey(resultRows, "prodOrderNo");
// 任务号
List<String> prodTaskNos = ObjectUtils.listKey(resultRows, "prodTaskNo");
// 锁生产计划
HPSCTools.HpSc004.lock(prodOrderNos);
// 锁生产订单
HPSCTools.HpSc005.lock(prodOrderNos);
// 锁生产任务
HPSCTools.HpSc005a.lock(prodTaskNos);
// 查询生产任务信息
Map<String, HPSC005B> dbSc005bMap = HPSCTools.HpSc005b.map(prodTaskNos);
// 数据校验
this.selectCheck(resultRows, dbSc005bMap);
// 生成入库单
this.selectData(resultRows, dbSc005bMap);
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "生成入库单失败");
}
return inInfo;
}
/**
* 数据校验
*
* @param resultRows
* @param dbSc005bMap
*/
public void selectCheck(List<Map> resultRows, Map<String, HPSC005B> dbSc005bMap) {
for (Map row : resultRows) {
String whCode = MapUtils.getString(row, "whCode");
BigDecimal applyNum = MapUtils.getBigDecimal(row, "applyNum");
HPSC005B fSc005b = new HPSC005B();
fSc005b.fromMap(row);
AssertUtils.isEmpty(whCode, String.format("任务号[%s]的仓库不存在为空", fSc005b.getProdTaskNo()));
HPSC005B dbSc005b = dbSc005bMap.get(fSc005b.getProdTaskNo());
AssertUtils.isTrue(ProdOrderStatusEnum.NOT_ASSIGN.getCode().equals(dbSc005b.getStatus()),
String.format("生产任务ID[%s]状态不是已分派,不允许操作", fSc005b.getId()));
// 完成数量是百分比
BigDecimal subNum = new BigDecimal("100").subtract(dbSc005b.getCompleteNum());
AssertUtils.isGt(applyNum, subNum, String.format("任务号[%s]申请数量[%s]%%不能大于未入库的数量[%s]%%",
fSc005b.getProdTaskNo(), applyNum, subNum));
// 校验是否存在巡检单
/* Map queryMap = new HashMap();
queryMap.put("prodTaskNo", fSc005b.getProdTaskNo());
queryMap.put("status", CommonConstant.YesNo.NO_0);
List<HPZL001> dbZl001s = dao.query(HPZL001.QUERY, queryMap);
AssertUtils.isNotEmpty(dbZl001s, String.format("任务号[%s]存在未处理的质量巡检单,请先处理质量巡检单",
fSc005b.getProdTaskNo()));*/
}
}
/**
* 生成入库单
*
* @param resultRows
* @param dbSc005bMap
*/
public void selectData(List<Map> resultRows, Map<String, HPSC005B> dbSc005bMap) {
for (Map row : resultRows) {
String whCode = MapUtils.getString(row, "whCode");
BigDecimal applyNum = MapUtils.getBigDecimal(row, "applyNum");
HPSC005B fSc005b = new HPSC005B();
fSc005b.fromMap(row);
HPSC005B dbSc005b = dbSc005bMap.get(fSc005b.getProdTaskNo());
HPKC003 newKc003 = BeanUtils.copy(dbSc005b, HPKC003.class);
newKc003.setProdNo(SequenceGenerator.getNextSequence(HPConstant.SequenceId.HPKC003_PROD_NO));
newKc003.setDocumentDate(DateUtils.shortDate());
newKc003.setWhCode(whCode);
newKc003.setWhName(HPPZTools.HpPz007.getByCode(whCode).getWhName());
newKc003.setRemark(MapUtils.getString(row, "remark1"));
newKc003.setAmount(applyNum);
// 百分比存的0~100,因此需要除以100
newKc003.setWeight(applyNum.multiply(dbSc005b.getTotalWt()).divide(new BigDecimal("100")));
newKc003.setDeleteFlag(CommonConstant.YesNo.NO_0);
DaoUtils.insert(HPKC003.INSERT, newKc003);
// 同步生产计划
HPSCTools.syncPlan(newKc003.getProdOrderNo(), newKc003.getAmount());
// 更新生产任务已完成数量
HPSCTools.HpSc005a.updateCompleteNum(fSc005b.getProdTaskNo(), applyNum);
// 修改库存
HPKCTools.updateProdStock(newKc003.getWhCode(), newKc003.getProdOrderNo(),
BigDecimal.ZERO, newKc003.getWeight(), fSc005b.getFactoryCode(), true);
}
}
}
package com.baosight.hpjx.hp.kc.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.common.InventTypeEnum;
import com.baosight.hpjx.common.ReturnStatusEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.kc.domain.HPKC004;
import com.baosight.hpjx.hp.kc.domain.HPKC010;
import com.baosight.hpjx.hp.kc.domain.HPKC011;
import com.baosight.hpjx.hp.kc.domain.HPKC013;
import com.baosight.hpjx.hp.kc.tools.HPKCTools;
import com.baosight.hpjx.util.BeanUtils;
import com.baosight.hpjx.util.CommonMethod;
import com.baosight.hpjx.util.EiInfoUtils;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.ObjectUtils;
import com.baosight.hpjx.util.StringUtil;
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 java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author:songx
* @date:2024/1/25,22:22
*/
public class ServiceHPKC104 extends ServiceBase {
// 指定存货类型
private static final Integer[] DEFAULT_INVENT_CODE = {InventTypeEnum.RAW.getCode(),
InventTypeEnum.CONSUMABLE.getCode(), InventTypeEnum.SEMI_FINISHED_PRODUCT.getCode(),
InventTypeEnum.FINISHED_PRODUCT.getCode()};
/**
* 画面初始化
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "销售出库单",operType = "查询",operDesc = "初始化")
public EiInfo initLoad(EiInfo inInfo) {
try {
Map queryMap = new HashMap();
queryMap.put("inventTypes", DEFAULT_INVENT_CODE);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.WH_RECORD_BLOCK_ID), queryMap);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.INVENT_NAME_BLOCK_ID), queryMap);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.INVENT_SPEC_BLOCK_ID), queryMap, false);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.SPEC_NAME_BLOCK_ID), queryMap, false);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.FACTORY_RECORD_BLOCK_ID), null, false);
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HPKC004().eiMetadata);
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
/**
* 查询操作
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "销售出库单",operType = "查询",operDesc = "查询")
@Override
public EiInfo query(EiInfo inInfo) {
try {
Map queryRow = EiInfoUtils.getFirstRow(inInfo);
String receiptDate = MapUtils.getString(queryRow, "receiptDate");
queryRow.put("receiptDate", StringUtil.removeSpecifiedCharacter(receiptDate,
StringUtil.DEFAULT_CHARACTER_TO_BE_REMOVED));
queryRow.put("inventTypes", DEFAULT_INVENT_CODE);
inInfo = super.query(inInfo, HPKC004.QUERY, new HPKC004());
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
return inInfo;
}
/**
* 删除操作
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "销售出库单",operType = "删除",operDesc = "删除")
public EiInfo delete(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 销售单号
List<String> saleNos = ObjectUtils.listKey(resultRows, "saleNo");
// 锁记录
HPKCTools.HpKc004.lock(saleNos);
// 查询数据库记录
Map<String, HPKC004> mapKc004 = HPKCTools.HpKc004.map(saleNos);
for (int i = 0; i < resultRows.size(); i++) {
HPKC011 hpkc011 = null;
HPKC010 hpkc010 = null;
HPKC004 fKc004 = new HPKC004();
fKc004.fromMap(resultRows.get(i));
if (!fKc004.getSubInventCode().equals(" "))
hpkc011 = HPKCTools.HpKc011.listById(fKc004.getKcId());
else
hpkc010 = HPKCTools.HpKc010.listById(fKc004.getKcId());
DaoUtils.update(HPKC004.DELETE, fKc004);
// 生成红冲记录
HPKC004 dbKc004 = mapKc004.get(fKc004.getSaleNo());
HPKC004 newKc004 = BeanUtils.copy(dbKc004, HPKC004.class);
newKc004.setSaleNo(SequenceGenerator.getNextSequence(HPConstant.SequenceId.HPKC004_SALE_NO));
newKc004.setAmount(dbKc004.getAmount().negate());
newKc004.setWeight(dbKc004.getWeight().negate());
newKc004.setOldSaleNo(dbKc004.getSaleNo());
newKc004.setProjCode(dbKc004.getProjCode());
newKc004.setProjName(dbKc004.getProjName());
newKc004.setIsPrint(CommonConstant.YesNo.NO_0);
newKc004.setDeleteFlag(CommonConstant.YesNo.YES_1);
DaoUtils.insert(HPKC004.INSERT, newKc004);
// 修改库存
if (hpkc010 != null) {
HPKCTools.updateStock(dbKc004.getWhCode(), hpkc010.getInventRecordId(),
dbKc004.getAmount(), dbKc004.getWeight(), hpkc010.getFactoryCode());
} else {
HPKCTools.updateProdStock(dbKc004.getWhCode(), dbKc004.getProdNo(),
BigDecimal.ZERO, dbKc004.getWeight(), hpkc011.getFactoryCode(), true);
}
}
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据删除成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "删除失败");
}
return inInfo;
}
/**
* 删除操作
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "销售出库单",operType = "修改",operDesc = "申请退货")
public EiInfo returnApply(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 销售单号
List<String> saleNos = ObjectUtils.listKey(resultRows, "saleNo");
// 锁记录
HPKCTools.HpKc004.lock(saleNos);
for (int i = 0; i < resultRows.size(); i++) {
HPKC004 fKc004 = new HPKC004();
fKc004.fromMap(resultRows.get(i));
DaoUtils.update("HPKC004.returnApply", fKc004);
HPKC013 hpkc013 = new HPKC013();
BeanUtils.copyProperties(fKc004,hpkc013);
hpkc013.setReturnNo(SequenceGenerator.getNextSequence(HPConstant.SequenceId.HPKC013_RETURN_NO));
hpkc013.setReturnStatus(ReturnStatusEnum.RETURNING.getCode());
DaoUtils.update(HPKC013.INSERT, hpkc013);
}
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据申请退货成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "删除失败");
}
return inInfo;
}
}
package com.baosight.hpjx.hp.kc.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.kc.domain.HPKC004;
import com.baosight.hpjx.hp.kc.domain.HPKC011;
import com.baosight.hpjx.hp.kc.tools.HPKCTools;
import com.baosight.hpjx.util.AssertUtils;
import com.baosight.hpjx.util.BeanUtils;
import com.baosight.hpjx.util.CommonMethod;
import com.baosight.hpjx.util.DateUtils;
import com.baosight.hpjx.util.EiInfoUtils;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.MapUtils;
import com.baosight.hpjx.util.ObjectUtils;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* 销售出库单挑选库存
*
* @author:songx
* @date:2022/7/11,11:08
*/
public class ServiceHPKC104A extends ServiceEPBase {
/**
* 初始化
*
* @param inInfo
* @return
*/
@Override
@OperationLogAnnotation(operModul = "库存查询", operType = "查询", operDesc = "销售出库单-库存查询-初始化")
public EiInfo initLoad(EiInfo inInfo) {
try {
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.FACTORY_RECORD_BLOCK_ID), null, false);
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HPKC011().eiMetadata);
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
/**
* 查询数据列表
*
* @param inInfo
* @return
*/
@Override
@OperationLogAnnotation(operModul = "库存查询", operType = "查询", operDesc = "销售出库单-库存查询-查询")
public EiInfo query(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
queryMap.put("isWeight", CommonConstant.YesNo.YES_1);
inInfo = super.query(inInfo, HPKC011.QUERYKC, new HPKC011());
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
return inInfo;
}
/**
* 生成出库单
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "库存查询", operType = "插入", operDesc = "销售出库单-库存查询-生成出库单")
public EiInfo select(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 库存ID
List<Long> ids = ObjectUtils.listKey(resultRows, "id");
// 行锁
HPKCTools.HpKc011.lock(ids);
// 获取库存信息
Map<Long, HPKC011> dbKc011Map = HPKCTools.HpKc011.map(ids);
// 状态校验
this.selectCheck(resultRows, dbKc011Map);
// 生成销售库单
this.selectData(resultRows, dbKc011Map);
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "生成出库单失败");
}
return inInfo;
}
/**
* 数据校验
*
* @param resultRows
* @param dbKc011Map
*/
private void selectCheck(List<Map> resultRows, Map<Long, HPKC011> dbKc011Map) {
for (Map row : resultRows) {
Long id = MapUtils.getLong(row, "id");
HPKC011 dbKc011 = dbKc011Map.get(id);
AssertUtils.isNull(dbKc011, "库存号[" + id + "]不存在!");
// 校验数量
// BigDecimal applyAmount = MapUtils.getBigDecimal(row, "applyAmount");
// AssertUtils.isGt(applyAmount, dbKc011.getAmount(), "库存号[" + id + "]可用数量不足!");
}
}
/**
* 写入数据
*
* @param resultRows
* @param dbKc011Map
*/
private void selectData(List<Map> resultRows, Map<Long, HPKC011> dbKc011Map) {
for (Map row : resultRows) {
BigDecimal applyWeight = MapUtils.getBigDecimal(row, "applyWeight");
String applyRemark = MapUtils.getString(row, "applyRemark");
Long kcId = MapUtils.getLong(row, "id");
HPKC011 dbKc011 = dbKc011Map.get(kcId);
HPKC004 newKc004 = BeanUtils.copy(dbKc011, HPKC004.class);
newKc004.setSaleNo(SequenceGenerator.getNextSequence(HPConstant.SequenceId.HPKC004_SALE_NO));
newKc004.setReceiptDate(DateUtils.shortDate());
newKc004.setAmount(BigDecimal.ZERO);
newKc004.setWeight(applyWeight);
newKc004.setInvWeight(dbKc011.getWeight());
newKc004.setDiffWeight(dbKc011.getWeight().subtract(applyWeight));
newKc004.setRemark(applyRemark);
newKc004.setKcId(kcId);
newKc004.setIsPrint(CommonConstant.YesNo.NO_0);
newKc004.setDeleteFlag(CommonConstant.YesNo.NO_0);
DaoUtils.insert(HPKC004.INSERT, newKc004);
// 修改库存数量
HPKCTools.updateProdStock(newKc004.getWhCode(), newKc004.getProdNo(),
BigDecimal.ZERO, newKc004.getWeight().negate(), dbKc011.getFactoryCode(), true);
}
}
}
package com.baosight.hpjx.hp.kc.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.common.InventTypeEnum;
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.kc.domain.HPKC011;
import com.baosight.hpjx.hp.pz.domain.HPPZ007;
import com.baosight.hpjx.hp.sc.domain.HPSC005;
import com.baosight.hpjx.hp.sc.tools.HPSCTools;
import com.baosight.hpjx.util.CommonMethod;
import com.baosight.hpjx.util.EiInfoUtils;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.contants.ACConstants;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import com.baosight.iplat4j.core.service.soa.XLocalManager;
import com.baosight.iplat4j.core.util.DateUtils;
import com.baosight.iplat4j.core.web.threadlocal.UserSession;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* @author:wwl
* @date:2024/1/23,10:51
*/
public class ServiceHPKC111 extends ServiceBase {
/**
* 画面初始化
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "产品库存管理", operType = "查润", operDesc = "初始化")
public EiInfo initLoad(EiInfo inInfo) {
HPKC011 HPKC011 = new HPKC011();
EiInfo outInfo = super.initLoad(inInfo, HPKC011);
outInfo.getBlock(EiConstant.resultBlock).getRows().clear();
Map paramMap = new HashMap<String, Object>() {{
put("inventTypes", InventTypeEnum.getProdTypes());
}};
CommonMethod.initBlock(outInfo, Arrays.asList(DdynamicEnum.FACTORY_RECORD_BLOCK_ID), null, false);
CommonMethod.initBlock(outInfo, Arrays.asList(DdynamicEnum.WH_RECORD_BLOCK_ID), paramMap);
CommonMethod.initBlock(outInfo, Arrays.asList(DdynamicEnum.MATERIAL_RECORD_BLOCK_ID), paramMap);
return outInfo;
}
/**
* 查询操作.
*/
@Override
@OperationLogAnnotation(operModul = "产品库存管理", operType = "查润", operDesc = "查询")
public EiInfo query(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
queryMap.put("isWeight", CommonConstant.YesNo.YES_1);
inInfo = super.query(inInfo, HPKC011.QUERY, new HPKC011());
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
return inInfo;
}
/**
* 新增操作.
*/
@Override
@OperationLogAnnotation(operModul = "产品库存管理", operType = "新增", operDesc = "新增")
public EiInfo insert(EiInfo inInfo) {
try {
CommonMethod.creatorInfo(inInfo, EiConstant.resultBlock);
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
for (int i = 0; i < resultRows.size(); i++) {
HPKC011 fKc010 = new HPKC011();
fKc010.fromMap(resultRows.get(i));
// 设置基础信息
DaoUtils.insert(HPKC011.INSERT, fKc010);
}
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据新增成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "新增失败");
}
return inInfo;
}
/**
* 更新库存
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "产品库存管理", operType = "修改", operDesc = "更新库存")
public EiInfo updateStock(EiInfo inInfo) {
String whCode = inInfo.getString("whCode");
String prodNo = inInfo.getString("prodNo");
String factoryCode = inInfo.getString("factoryCode");
BigDecimal amount = new BigDecimal(inInfo.getString("amount"));
BigDecimal weight = new BigDecimal(inInfo.getString("weight"));
String companyCode = UserSessionUtils.getCompanyCode();
try {
checkUpdateStockParam(companyCode, whCode, prodNo, amount, weight);
HPKC011 newObj = generatorBaseInfo(companyCode, whCode, prodNo, amount, weight);
List<Map> list = dao.query("HPKC011.queryByCondition", new HashMap<String, Object>() {{
put("companyCode", companyCode);
put("whCode", whCode);
put("prodNo", prodNo);
}});
if (CollectionUtils.isEmpty(list)) {
//新增
if (amount.compareTo(BigDecimal.ZERO) < 0
|| weight.compareTo(BigDecimal.ZERO) < 0) {
throw new PlatException("当前库存为空,库存变更数量与重量不能小于等于0!");
}
newObj.setFactoryCode(factoryCode);
generatorBaseInfo(newObj);
DaoUtils.insert("HPKC011.insert", newObj);
} else {
//修改
HPKC011 oldObj = new HPKC011();
oldObj.fromMap(list.get(0));
BigDecimal afterAmout = oldObj.getAmount().add(amount);
BigDecimal afterWeight = oldObj.getWeight().add(weight);
if (afterAmout.compareTo(BigDecimal.ZERO) < 0 || afterWeight.compareTo(BigDecimal.ZERO) < 0) {
throw new PlatException("库存更新失败,出库数量与重量不能大于当前库存!");
}
oldObj.setAmount(afterAmout);
oldObj.setWeight(afterWeight);
oldObj.setUpdatedBy(newObj.getUpdatedBy());
oldObj.setUpdatedName(newObj.getUpdatedName());
oldObj.setUpdatedTime(newObj.getUpdatedTime());
int result = DaoUtils.update("HPKC011.updateStock", oldObj);
if (result != 1) {
throw new PlatException("库存更新失败,库存已发生变更或系统异常,请重试!");
}
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsg("库存更新成功!");
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "库存更新失败!");
}
return inInfo;
}
/**
* 生成库存对象
*
* @param companyCode
* @param whCode
* @param prodNo
* @param amout
* @param weight
* @reutrn HPKC011
*/
private HPKC011 generatorBaseInfo(String companyCode, String whCode, String prodNo, BigDecimal amout,
BigDecimal weight) {
HPKC011 hpkc011 = new HPKC011();
hpkc011.setCompanyCode(companyCode);
hpkc011.setWhCode(whCode);
hpkc011.setProdNo(prodNo);
hpkc011.setAmount(amout);
hpkc011.setWeight(weight);
String userId = UserSession.getLoginName();
String userName = UserSession.getLoginCName();
String time = DateUtils.curDateTimeStr14();
hpkc011.setCreatedBy(userId);
hpkc011.setCreatedName(userName);
hpkc011.setCreatedTime(time);
hpkc011.setUpdatedBy(userId);
hpkc011.setUpdatedName(userName);
hpkc011.setUpdatedTime(time);
return hpkc011;
}
private void generatorBaseInfo(HPKC011 hpkc011) {
EiInfo inInfo = new EiInfo();
try {
inInfo.set("whCode", hpkc011.getWhCode());
inInfo.set(EiConstant.serviceName, "HPPZ007");
inInfo.set(EiConstant.methodName, "queryByWhCode");
EiInfo outInfo = XLocalManager.call(inInfo);
List<HPPZ007> whNameList = (List) outInfo.get("list");
hpkc011.setWhName(whNameList.get(0).getWhName());
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "库存更新失败!");
throw new PlatException("仓库编码异常,找不到对应的仓库档案!");
}
try {
HPSC005 hpsc005 = HPSCTools.HpSc005.get(hpkc011.getProdNo());
hpkc011.setProjCode(hpsc005.getProjCode());
hpkc011.setProjName(hpsc005.getProjName());
hpkc011.setInventCode(hpsc005.getPrdtCode());
hpkc011.setInventName(hpsc005.getPrdtName());
hpkc011.setSubInventCode(hpsc005.getPartCode());
hpkc011.setSubInventName(hpsc005.getPartName());
hpkc011.setLength(hpsc005.getPartLength());
hpkc011.setWidth(hpsc005.getPartWidth());
hpkc011.setThick(hpsc005.getPartThick());
hpkc011.setPrdtSpec(hpsc005.getPrdtSpec());
hpkc011.setUnitWeight(hpsc005.getUnitWt());
hpkc011.setRemark(hpsc005.getRemark1());
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "库存更新失败!");
throw new PlatException("生产单号异常,找不到对应的生产订单!");
}
hpkc011.setVersion(new Integer(1));
}
/**
* 校验库存变更请求参数
*
* @param companyCode
* @param whCode
* @param prodNo
* @param amout
* @param weight
*/
private void checkUpdateStockParam(String companyCode, String whCode, String prodNo
, BigDecimal amout, BigDecimal weight) {
if (StringUtils.isBlank(companyCode)) {
throw new PlatException("企业编码不能为空!");
}
if (StringUtils.isBlank(whCode)) {
throw new PlatException("仓库编码不能为空!");
}
if (StringUtils.isBlank(prodNo)) {
throw new PlatException("生产单号不能为空!");
}
if (Objects.isNull(amout) ||
Objects.isNull(amout)) {
throw new PlatException("库存变更数量或重量不能为空!");
}
if (amout.compareTo(BigDecimal.ZERO) == 0
&& weight.compareTo(BigDecimal.ZERO) == 0) {
throw new PlatException("库存变更数量或重量不能为0)!");
}
}
}
......@@ -23,6 +23,8 @@
AMOUNT as "amount", <!-- 数量 -->
UNIT_WEIGHT as "unitWeight", <!-- 单重 -->
WEIGHT as "weight", <!-- 重量 -->
INV_WEIGHT as "invWeight", <!-- 库存重量 -->
DIFF_WEIGHT as "diffWeight", <!-- 差异重量 -->
REMARK as "remark", <!-- 备注 -->
KC_ID as "kcId", <!-- 库存ID -->
OLD_SALE_NO as "oldSaleNo", <!-- 原销售单号 -->
......@@ -125,6 +127,12 @@
<isNotEmpty prepend=" AND " property="createdDateTo">
CREATED_TIME &lt;= CONCAT(REPLACE(#createdDateTo#, '-', ''), '235959')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="geDiffWeight">
DIFF_WEIGHT &gt;= #geDiffWeight#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="leDiffWeight">
DIFF_WEIGHT &lt;= #leDiffWeight#
</isNotEmpty>
</sql>
<!-- 公共修改字段 -->
......@@ -181,6 +189,8 @@
AMOUNT, <!-- 数量 -->
UNIT_WEIGHT, <!-- 单重 -->
WEIGHT, <!-- 重量 -->
INV_WEIGHT, <!-- 库存重量 -->
DIFF_WEIGHT, <!-- 差异重量 -->
REMARK, <!-- 备注 -->
KC_ID, <!-- 库存ID -->
OLD_SALE_NO, <!-- 原销售单号 -->
......@@ -195,11 +205,12 @@
) VALUES (
#companyCode#, #depCode#, #receiptDate#, #saleNo#, #whCode#, #whName#, #prodNo#,
#projCode#, #projName#, #inventCode#, #inventName#, #subInventCode#, #subInventName#,
#length#, #width#, #thick#, #amount#, #unitWeight#, #weight#, #remark#, #kcId#,
#oldSaleNo#, #isPrint#, #isReturn#, #createdBy#, #createdName#, #createdTime#, #deleteFlag#,#factoryCode#, #factoryName#
#length#, #width#, #thick#, #amount#, #unitWeight#, #weight#, #invWeight#, #diffWeight#,
#remark#, #kcId#, #oldSaleNo#, #isPrint#, #isReturn#, #createdBy#, #createdName#,
#createdTime#, #deleteFlag#,#factoryCode#, #factoryName#
)
</insert>
<!-- 逻辑删除 -->
<delete id="delete">
UPDATE ${hpjxSchema}.T_HPKC004 SET DELETE_FLAG = 1 WHERE ID = #id#
......
......@@ -103,6 +103,9 @@
<isNotEmpty prepend=" AND " property="isAmount">
a.AMOUNT != 0
</isNotEmpty>
<isNotEmpty prepend=" AND " property="isWeight">
a.WEIGHT > 0
</isNotEmpty>
</sql>
<sql id="customCondition">
......
package com.baosight.hpjx.hp.kc.tools;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.hp.kc.domain.HPKC004;
import com.baosight.hpjx.util.DateUtils;
import com.baosight.hpjx.util.ExcelUtils;
......@@ -47,12 +48,13 @@ public class CKExcelTools {
HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();
Map parameter = StringUtils.encodeParam(request.getParameter("parameter"));
// 获取数据
String isWeight = (String) parameter.get("isWeight");
List<Long> saleIds = (List<Long>) parameter.get("saleIds");
List<HPKC004> dbKc004s = HPKCTools.HpKc004.listById(saleIds);
// 数据格式转换
Map dataMap = convertData(dbKc004s);
// 构建excel
HSSFWorkbook workbook = buildExcel(dataMap);
HSSFWorkbook workbook = buildExcel(dataMap, isWeight);
String fileName = "出库单-" + DateUtils.shortYmdhmss() + ".xls";
ExcelUtils.download(fileName, workbook, response);
// 更新状态
......@@ -91,8 +93,9 @@ public class CKExcelTools {
* 导出Excel
*
* @param dataMap 数据集
* @param isWeight
*/
public static HSSFWorkbook buildExcel(Map dataMap) {
public static HSSFWorkbook buildExcel(Map dataMap, String isWeight) {
HSSFWorkbook workbook = new HSSFWorkbook();
// 在Workbook中,创建一个sheet,对应Excel中的工作薄(sheet)
HSSFSheet sheet = workbook.createSheet("出库单");
......@@ -106,7 +109,7 @@ public class CKExcelTools {
// 第1行
startRow = buildRow1(workbook, sheet, startRow, dataMap);
// 第2行:标题栏
startRow = buildRow2(workbook, sheet, startRow);
startRow = buildRow2(workbook, sheet, startRow, isWeight);
// 第2行:标题栏
startRow = buildRow3(workbook, sheet, startRow);
// 遍历数据行,excel行从第3行开始
......@@ -117,7 +120,7 @@ public class CKExcelTools {
// 组名称
startRow = buildGroupRow(workbook, sheet, key, startRow);
// 明细数据,返回末尾行数
startRow = buildChildRow(workbook, sheet, values, startRow);
startRow = buildChildRow(workbook, sheet, values, startRow, isWeight);
}
// 页脚
buildFoot(workbook, sheet, startRow);
......@@ -170,8 +173,10 @@ public class CKExcelTools {
* @param sheet
* @param values
* @param startRow
* @param isWeight
*/
private static int buildChildRow(HSSFWorkbook workbook, HSSFSheet sheet, List<HPKC004> values, int startRow) {
private static int buildChildRow(HSSFWorkbook workbook, HSSFSheet sheet, List<HPKC004> values, int startRow,
String isWeight) {
for (int i = 0; i < values.size(); i++) {
HPKC004 valueMap = values.get(i);
HSSFRow row = sheet.createRow(startRow);
......@@ -200,10 +205,14 @@ public class CKExcelTools {
HSSFCell cell1_4 = row.createCell(4);
cell1_4.setCellValue(valueMap.getThick() == null ? "" : valueMap.getThick().toString());
cell1_4.setCellStyle(getCellStyle(workbook));
// 数量
// 数量/重量
HSSFCell cell1_5 = row.createCell(5);
cell1_5.setCellValue(valueMap.getAmount() + "");
cell1_5.setCellStyle(getCellStyle(workbook));
if (CommonConstant.YesNo.YES.equals(isWeight)) {
cell1_5.setCellValue(valueMap.getWeight() + "");
} else {
cell1_5.setCellValue(valueMap.getAmount() + "");
}
// 备注
HSSFCell cell1_6 = row.createCell(6);
cell1_6.setCellValue(valueMap.getRemark());
......@@ -279,8 +288,9 @@ public class CKExcelTools {
* @param workbook
* @param sheet
* @param startRow
* @param isWeight
*/
private static int buildRow2(HSSFWorkbook workbook, HSSFSheet sheet, int startRow) {
private static int buildRow2(HSSFWorkbook workbook, HSSFSheet sheet, int startRow, String isWeight) {
// 2.第2行标题行
HSSFRow row2 = sheet.createRow(startRow);
row2.setHeight((short) (20 * 20));
......@@ -304,9 +314,9 @@ public class CKExcelTools {
cell2_3.setCellStyle(getCellStyle(workbook, true));
HSSFCell cell2_4 = row2.createCell(4);
cell2_4.setCellStyle(getCellStyle(workbook, true));
// 2.5、数量
// 2.5、数量/重量
HSSFCell cell2_5 = row2.createCell(5);
cell2_5.setCellValue("数量");
cell2_5.setCellValue(CommonConstant.YesNo.YES.equals(isWeight) ? "重量(T)" : "数量");
cell2_5.setCellStyle(getCellStyle(workbook, HorizontalAlignment.CENTER, VerticalAlignment.CENTER, true,
true));
// 2.6、备注
......
package com.baosight.hpjx.hp.kc.tools;
import com.baosight.hpjx.common.ProdOrderStatusEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoBase;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.constant.HPSqlConstant;
import com.baosight.hpjx.hp.kc.domain.*;
import com.baosight.hpjx.hp.pz.tools.HPPZTools;
import com.baosight.hpjx.hp.sc.domain.HPSC005B;
import com.baosight.hpjx.hp.sc.domain.HPSC106;
import com.baosight.hpjx.hp.sc.tools.HPSCTools;
import com.baosight.hpjx.util.*;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.soa.XLocalManager;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -197,6 +206,55 @@ public class HPKCTools {
}
return results.stream().collect(Collectors.toMap(HPKC003::getProdNo, item -> item));
}
/**
* 添加生产入库
*
* @param hpsc106
* @return
*/
public static void addHpKc003(HPSC106 hpsc106) {
// 订单号
String prodOrderNo = hpsc106.getProdOrderNo();
// 任务号
String prodTaskNo = hpsc106.getProdTaskNo();
// 锁生产计划
HPSCTools.HpSc004.lock(prodOrderNo);
// 锁生产订单
HPSCTools.HpSc005.lock(prodOrderNo);
// 锁生产任务
HPSCTools.HpSc005a.lock(prodTaskNo);
// 查询生产任务信息
Map<String, HPSC005B> dbSc005bMap = HPSCTools.HpSc005b.map(prodTaskNo);
List<Map<String,String>> mapList = DaoBase.getInstance().query("HPPZ007.queryComboBox", new HashMap<String, Object>(){{
put("inventTypes", new String[]{"3"});
}});
AssertUtils.isEmpty(mapList, "仓库不存在");
// 生成入库单
BigDecimal totalWeight = hpsc106.getTotalWeight();
BigDecimal quantity = hpsc106.getQuantity();
HPSC005B fSc005b = BeanUtils.copy(hpsc106, HPSC005B.class);
HPSC005B dbSc005b = dbSc005bMap.get(fSc005b.getProdTaskNo());
HPKC003 newKc003 = BeanUtils.copy(dbSc005b, HPKC003.class);
newKc003.setProdNo(SequenceGenerator.getNextSequence(HPConstant.SequenceId.HPKC003_PROD_NO));
newKc003.setDocumentDate(DateUtils.shortDate());
newKc003.setWhCode(mapList.get(0).get("whCode"));
newKc003.setWhName(mapList.get(0).get("whName"));
//newKc003.setRemark(MapUtils.getString(row, "remark1"));
newKc003.setAmount(quantity);
newKc003.setWeight(totalWeight);
newKc003.setDeleteFlag(CommonConstant.YesNo.NO_0);
DaoUtils.insert(HPKC003.INSERT, newKc003);
// 同步生产计划
HPSCTools.syncPlan(newKc003.getProdOrderNo(), newKc003.getAmount(), newKc003.getWeight());
// 更新生产任务已完成数量
HPSCTools.HpSc005a.updateCompleteNum(fSc005b.getProdTaskNo(), quantity);
// 修改库存
HPKCTools.updateProdStock(newKc003.getWhCode(), newKc003.getProdOrderNo(),
newKc003.getAmount(), newKc003.getWeight(),fSc005b.getFactoryCode());
}
}
/**
......@@ -742,8 +800,25 @@ public class HPKCTools {
* @param amount
* @param weight
*/
public static void updateProdStock(String whCode, String prodNo, BigDecimal amount, BigDecimal weight,String factoryCode) {
if (amount.compareTo(BigDecimal.ZERO) == 0 && weight.compareTo(BigDecimal.ZERO) == 0) {
public static void updateProdStock(String whCode, String prodNo, BigDecimal amount, BigDecimal weight,
String factoryCode) {
updateProdStock(whCode, prodNo, amount, weight, factoryCode, false);
}
/**
* 更新产品库存
*
* @param whCode
* @param prodNo
* @param amount
* @param weight
* @param isOnlyWeight 只有重量
*/
public static void updateProdStock(String whCode, String prodNo, BigDecimal amount, BigDecimal weight,
String factoryCode, boolean isOnlyWeight) {
// 只有重量的时候,不校验数量
if ((!isOnlyWeight && amount.compareTo(BigDecimal.ZERO) == 0)
|| weight.compareTo(BigDecimal.ZERO) == 0) {
return;
}
EiInfo inInfo = new EiInfo();
......@@ -752,11 +827,12 @@ public class HPKCTools {
inInfo.set("amount", amount);
inInfo.set("weight", weight);
inInfo.set("factoryCode", factoryCode);
inInfo.set("isOnlyWeight", isOnlyWeight);
inInfo.set(EiConstant.serviceName, "HPKC011");
inInfo.set(EiConstant.methodName, "updateStock");
EiInfo outInfo = XLocalManager.call(inInfo);
if (outInfo.getStatus() < 0) {
throw new PlatException("新库存失败:" + outInfo.getMsg());
throw new PlatException("新库存失败:" + outInfo.getMsg());
}
}
......
......@@ -54,7 +54,7 @@ public class ServiceHPPZ009A extends ServiceEPBase {
try {
// 项目环境
String projectEnv = ProjectInfo.getProjectEnv();
if (CommonConstant.projectEnv.RUN.equalsIgnoreCase(projectEnv)) {
if (CommonConstant.ProjectEnv.RUN.equalsIgnoreCase(projectEnv)) {
inInfo = super.query(inInfo, "HPPZ009A.queryRun", new HPPZ009A());
} else {
inInfo = super.query(inInfo, "HPPZ009A.queryDev", new HPPZ009A());
......@@ -132,7 +132,7 @@ public class ServiceHPPZ009A extends ServiceEPBase {
String realPath = list.get(0).getRealPath();
// 项目环境
String projectEnv = ProjectInfo.getProjectEnv();
if (projectEnv.equals(CommonConstant.projectEnv.RUN)) {
if (projectEnv.equals(CommonConstant.ProjectEnv.RUN)) {
EiInfo queryInfo = new EiInfo();
queryInfo.set(HPPZ009A.FIELD_DOC_ID,list.get(0).getDocId());
//获取文档信息
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd"> <!-- table information
Generate time : 2024-05-14 13:52:21
Version : 1.0
schema : hpjx
tableName : T_HPPZ009A
ID BIGINT NOT NULL primarykey,
COMPANY_CODE VARCHAR NOT NULL,
DEP_CODE VARCHAR NOT NULL,
PARENT_ID BIGINT,
DOC_ID VARCHAR,
CREATED_BY VARCHAR,
CREATED_NAME VARCHAR,
CREATED_TIME VARCHAR,
UPDATED_BY VARCHAR,
UPDATED_NAME VARCHAR,
UPDATED_TIME VARCHAR
-->
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="HPPZ009A">
<sql id="column">
......
......@@ -263,6 +263,22 @@ public class HPPZTools {
}
/**
* 查询企业信息
*
* @param companyCode
* @return
*/
public static HPPZ009 queryByCode(String companyCode) {
if (StringUtils.isBlank(companyCode)) {
return null;
}
Map queryMap = new HashMap();
queryMap.put("companyCode", companyCode);
List<HPPZ009> pz009s = DaoBase.getInstance().query("HPPZ009.query", queryMap);
return CollectionUtils.isEmpty(pz009s) ? null : pz009s.get(0);
}
/**
* 企业是否启用
*
* @param companyCode
......
package com.baosight.hpjx.hp.sb.domain;
import com.baosight.hpjx.util.DateUtils;
import com.baosight.iplat4j.core.util.NumberUtils;
import com.baosight.iplat4j.core.ei.EiColumn;
import com.baosight.iplat4j.core.data.DaoEPBase;
......@@ -42,6 +43,13 @@ public class HPSB003 extends DaoEPBase {
public static final String FIELD_DEVICE_USER_ID = "deviceUserId"; /* 设备负责人*/
public static final String FIELD_DEVICE_STATUS = "deviceStatus"; /* 设备状态 0-停止 1-启用*/
public static final String FIELD_SUP_CODE = "supCode"; /* 供应商编码*/
public static final String FIELD_SUP_NAME = "supName"; /* 供应商名称*/
public static final String FIELD_HEAD_NAME = "headName"; /* 负责人*/
public static final String FIELD_PHONE_NAME = "phoneName"; /* 负责人联系方式*/
public static final String FIELD_ADDRESS = "address"; /* 地址*/
public static final String FIELD_PERIOD_DAYS = "periodDays";
public static final String COL_ID = "ID"; /* ID*/
public static final String COL_COMPANY_CODE = "COMPANY_CODE"; /* 公司编码*/
public static final String COL_DEP_CODE = "DEP_CODE"; /* 部门编码*/
......@@ -70,6 +78,8 @@ public class HPSB003 extends DaoEPBase {
public static final String DELETE = "HPSB003.delete";
public static final String DELETE_FLAG = "HPSB003.deleteFlag";
public static final String UPDATE_DEVICE_STATUS = "HPSB003.updateDeviceStatus";
public static final String UPDATE_STATUS = "HPSB003.updateStatus";
public static final String UPDATE_MAINTAIN_DATE = "HPSB003.updateMaintainDate";
private Long id; /* ID*/
private String companyCode = " "; /* 公司编码*/
......@@ -91,6 +101,12 @@ public class HPSB003 extends DaoEPBase {
private String maintainDate = " "; /* 保养日期*/
private String deviceUserId = " "; /* 设备负责人*/
private Integer deviceStatus = 0; /* 设备状态 0-停止 1-启用*/
private String supCode = " "; /* 供应商编码*/
private String supName = " "; /* 供应商名称*/
private String headName = " "; /* 联系人*/
private String phoneName = " "; /* 联系电话*/
private String address = " "; /* 地址*/
public Integer periodDays = 0;
/**
* initialize the metadata.
......@@ -179,6 +195,29 @@ public class HPSB003 extends DaoEPBase {
eiColumn.setDescName("设备状态 0-停止 1-启用");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_SUP_CODE);
eiColumn.setDescName("供应商编码");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_SUP_NAME);
eiColumn.setDescName("供应商名称");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_HEAD_NAME);
eiColumn.setDescName("负责人");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_PHONE_NAME);
eiColumn.setDescName("负责人联系方式");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_ADDRESS);
eiColumn.setDescName("地址");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_PERIOD_DAYS);
eiColumn.setDescName("保养周期天数");
eiMetadata.addMeta(eiColumn);
}
......@@ -509,6 +548,55 @@ public class HPSB003 extends DaoEPBase {
public void setDeviceStatus(Integer deviceStatus) {
this.deviceStatus = deviceStatus;
}
public String getSupCode() {
return supCode;
}
public void setSupCode(String supCode) {
this.supCode = supCode;
}
public String getSupName() {
return supName;
}
public void setSupName(String supName) {
this.supName = supName;
}
public String getHeadName() {
return headName;
}
public void setHeadName(String headName) {
this.headName = headName;
}
public String getPhoneName() {
return phoneName;
}
public void setPhoneName(String phoneName) {
this.phoneName = phoneName;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public Integer getPeriodDays() {
return periodDays;
}
public void setPeriodDays(Integer periodDays) {
this.periodDays = periodDays;
}
/**
* get the value from Map.
*
......@@ -534,10 +622,16 @@ public class HPSB003 extends DaoEPBase {
setDeviceCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_DEVICE_CODE)), deviceCode));
setDeviceName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_DEVICE_NAME)), deviceName));
setDeviceModel(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_DEVICE_MODEL)), deviceModel));
setPurchaseDate(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_PURCHASE_DATE)), purchaseDate));
setMaintainDate(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_MAINTAIN_DATE)), maintainDate));
setPurchaseDate(StringUtils.defaultIfEmpty(StringUtils.toString(DateUtils.formatShort(map.get(FIELD_PURCHASE_DATE))), purchaseDate));
setMaintainDate(StringUtils.defaultIfEmpty(StringUtils.toString(DateUtils.formatShort(map.get(FIELD_MAINTAIN_DATE))), maintainDate));
setDeviceUserId(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_DEVICE_USER_ID)), deviceUserId));
setDeviceStatus(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_DEVICE_STATUS)), deviceStatus));
setSupCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_SUP_CODE)), supCode));
setSupName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_SUP_NAME)), supName));
setHeadName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_HEAD_NAME)), headName));
setPhoneName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_PHONE_NAME)), phoneName));
setAddress(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_ADDRESS)), address));
setPeriodDays(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_PERIOD_DAYS)), periodDays));
}
/**
......@@ -567,6 +661,12 @@ public class HPSB003 extends DaoEPBase {
map.put(FIELD_MAINTAIN_DATE, StringUtils.toString(maintainDate, eiMetadata.getMeta(FIELD_MAINTAIN_DATE)));
map.put(FIELD_DEVICE_USER_ID, StringUtils.toString(deviceUserId, eiMetadata.getMeta(FIELD_DEVICE_USER_ID)));
map.put(FIELD_DEVICE_STATUS, StringUtils.toString(deviceStatus, eiMetadata.getMeta(FIELD_DEVICE_STATUS)));
map.put(FIELD_SUP_CODE, StringUtils.toString(supCode, eiMetadata.getMeta(FIELD_SUP_CODE)));
map.put(FIELD_SUP_NAME, StringUtils.toString(supName, eiMetadata.getMeta(FIELD_SUP_NAME)));
map.put(FIELD_HEAD_NAME, StringUtils.toString(headName, eiMetadata.getMeta(FIELD_HEAD_NAME)));
map.put(FIELD_PHONE_NAME, StringUtils.toString(phoneName, eiMetadata.getMeta(FIELD_PHONE_NAME)));
map.put(FIELD_ADDRESS, StringUtils.toString(address, eiMetadata.getMeta(FIELD_ADDRESS)));
map.put(FIELD_PERIOD_DAYS, StringUtils.toString(periodDays, eiMetadata.getMeta(FIELD_PERIOD_DAYS)));
return map;
}
......
......@@ -18,10 +18,7 @@ import com.baosight.iplat4j.core.resource.I18nMessages;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* @author LiuYang
......@@ -31,22 +28,27 @@ public class ServiceHPSB003 extends ServiceEPBase {
@Override
public EiInfo initLoad(EiInfo inInfo) {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HPSB003.FIELD_DELETE_FLAG, CommonConstant.YesNo.NO_0);
final EiInfo outEiInfo = super.query(inInfo, HPSB003.QUERY, new HPSB003());
//inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HPSB003.FIELD_DELETE_FLAG, CommonConstant.YesNo.NO_0);
//final EiInfo outEiInfo = super.query(inInfo, HPSB003.QUERY, new HPSB003());
//拼接名称 包含逻辑删除数据
CommonMethod.initBlock(outEiInfo,
Arrays.asList(DdynamicEnum.FACTORY_CODE_BOX_BLOCK_ID,DdynamicEnum.GROUP_CODE_BOX_BLOCK_ID,DdynamicEnum.USER_ID_BOX_BLOCK_ID),
CommonMethod.initBlock(inInfo,
Arrays.asList(
DdynamicEnum.FACTORY_CODE_BOX_BLOCK_ID,
DdynamicEnum.GROUP_CODE_BOX_BLOCK_ID,
DdynamicEnum.USER_ID_BOX_BLOCK_ID),
new HashMap<String,Object>(){}
);
return outEiInfo;
return inInfo;
}
@Override
public EiInfo query(EiInfo inInfo) {
EiBlock block = inInfo.getBlock(EiConstant.queryBlock);
String purchaseDate = block.getCellStr(ACConstants.ROW_CODE_0,HPSB003.FIELD_PURCHASE_DATE);
if (!purchaseDate.isEmpty()) {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0,HPSB003.FIELD_PURCHASE_DATE, StringUtil.removeHorizontalLine(purchaseDate));
if (!Objects.isNull(block)) {
String purchaseDate = block.getCellStr(ACConstants.ROW_CODE_0,HPSB003.FIELD_PURCHASE_DATE);
if (!purchaseDate.isEmpty()) {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0,HPSB003.FIELD_PURCHASE_DATE, StringUtil.removeHorizontalLine(purchaseDate));
}
}
inInfo.setCell(EiConstant.queryBlock,ACConstants.ROW_CODE_0, HPSB003.FIELD_DELETE_FLAG, CommonConstant.YesNo.NO_0);
return super.query(inInfo, HPSB003.QUERY,new HPSB003());
......@@ -66,14 +68,9 @@ public class ServiceHPSB003 extends ServiceEPBase {
DaoUtils.update(HPSB003.DELETE_FLAG, hpsb001);
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsgByKey("ep.1000", new String[]{String.valueOf(i), I18nMessages.getText("label.delete", "删除")});
inInfo.setMsg("操作成功!本次对[" + eiBlock.getRowCount() + "]条数据删除成功!");
} catch (PlatException e) {
e.printStackTrace();
inInfo.setStatus(EiConstant.STATUS_FAILURE);
ErrorCodeUtils.handleDeleteException(inInfo,i,e);
logError("删除失败", e.getMessage());
return inInfo;
LogUtils.setMsg(inInfo,e, "删除失败");
}
return inInfo;
}
......@@ -92,13 +89,9 @@ public class ServiceHPSB003 extends ServiceEPBase {
DaoUtils.update(HPSB003.UPDATE, hpsb001);
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsgByKey("ep.1000", new String[]{String.valueOf(i), I18nMessages.getText("label.update", "修改")});
inInfo.setMsg("操作成功!本次对[" + eiBlock.getRowCount() + "]条数据修改成功!");
} catch (PlatException e) {
e.printStackTrace();
inInfo.setStatus(EiConstant.STATUS_FAILURE);
ErrorCodeUtils.handleUpdateException(inInfo,i,e);
logError("修改失败", e.getMessage());
return inInfo;
LogUtils.setMsg(inInfo,e, "修改失败");
}
return inInfo;
}
......@@ -107,21 +100,17 @@ public class ServiceHPSB003 extends ServiceEPBase {
public EiInfo updateDeviceStatus(EiInfo inInfo) {
int i = 0;
try {
HPSB003 hpsb001 = new HPSB003();
HPSB003 hpsb003 = new HPSB003();
EiBlock eiBlock = inInfo.getBlock(EiConstant.resultBlock);
for (i = 0; i < eiBlock.getRowCount(); i++) {
Map<?, ?> map = eiBlock.getRow(i);
hpsb001.fromMap(map);
DaoUtils.update(HPSB003.UPDATE_DEVICE_STATUS, hpsb001);
hpsb003.fromMap(map);
DaoUtils.update(HPSB003.UPDATE_DEVICE_STATUS, hpsb003);
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsgByKey("ep.1000", new String[]{String.valueOf(i), I18nMessages.getText("label.update", "修改")});
inInfo.setMsg("操作成功!本次对[" + eiBlock.getRowCount() + "]条数据修改成功!");
} catch (PlatException e) {
e.printStackTrace();
inInfo.setStatus(EiConstant.STATUS_FAILURE);
ErrorCodeUtils.handleUpdateException(inInfo,i,e);
logError("修改失败", e.getMessage());
return inInfo;
LogUtils.setMsg(inInfo,e, "修改失败");
}
return inInfo;
}
......@@ -131,16 +120,15 @@ public class ServiceHPSB003 extends ServiceEPBase {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 写入数据
for (int i = 0; i < resultRows.size(); i++) {
for (Map resultRow : resultRows) {
HPSB003 hpsb003 = new HPSB003();
hpsb003.fromMap(resultRows.get(i));
hpsb003.fromMap(resultRow);
if (hpsb003.getId() == null || hpsb003.getId() == 0) {
this.add(hpsb003);
} else {
this.modify(hpsb003);
}
}
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据保存成功!");
} catch (Exception e) {
......@@ -169,23 +157,19 @@ public class ServiceHPSB003 extends ServiceEPBase {
public EiInfo insert(EiInfo inInfo) {
int i = 0;
try {
HPSB003 hpsb001 = new HPSB003();
HPSB003 hpsb003 = new HPSB003();
EiBlock eiBlock = inInfo.getBlock(EiConstant.resultBlock);
for (i = 0; i < eiBlock.getRowCount(); i++) {
Map<?, ?> map = eiBlock.getRow(i);
hpsb001.fromMap(map);
hpsb001.setDeleteFlag(CommonConstant.YesNo.NO_0);
Map<String,Object> queryMap = new HashMap<>();
queryDeviceCode(hpsb001);
DaoUtils.insert(HPSB003.INSERT, hpsb001);
hpsb003.fromMap(map);
hpsb003.setDeleteFlag(CommonConstant.YesNo.NO_0);
queryDeviceCode(hpsb003);
DaoUtils.insert(HPSB003.INSERT, hpsb003);
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsgByKey("ep.1000", new String[]{String.valueOf(i), I18nMessages.getText("label.insert", "新增")});
inInfo.setMsg("操作成功!本次对[" + eiBlock.getRowCount() + "]条数据新增成功!");
} catch (PlatException e) {
e.printStackTrace();
ErrorCodeUtils.handleInsertException(inInfo,i,e);
logError("新增失败", e.getMessage());
return inInfo;
LogUtils.setDetailMsg(inInfo, e, "新增失败");
}
return inInfo;
}
......
package com.baosight.hpjx.hp.sb.service;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.hp.sb.domain.HPSB003;
import com.baosight.hpjx.hp.sb.domain.HPSB003A;
import com.baosight.hpjx.hp.sb.domain.HPSB008;
import com.baosight.hpjx.util.CommonMethod;
import com.baosight.hpjx.util.contants.ACConstants;
import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiBlockMeta;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import java.util.Arrays;
/**
* @author LiuYang
* @version 1.0 2024/8/13
* @description 设备台账详情
*/
public class ServiceHPSB003A extends ServiceEPBase {
@Override
public EiInfo initLoad(EiInfo inInfo) {
//EiBlock queryBlock = inInfo.getBlock(EiConstant.queryBlock);
//queryBlock.setCell(ACConstants.ROW_CODE_0, HPSB003.FIELD_DELETE_FLAG, CommonConstant.YesNo.NO_0);
//queryBlock.set(EiConstant.offsetStr,EiConstant.defaultOffset);
//queryBlock.set(EiConstant.limitStr,EiConstant.defaultLimit);
//EiBlock resultBlock = new EiBlock(EiConstant.resultBlock);
//resultBlock.set(EiConstant.isCountFlag,true);
//inInfo.setBlock(resultBlock);
//inInfo = super.query(inInfo, HPSB003A.RESULT_QUERY, new HPSB003A(),false, new EiBlockMeta(),EiConstant.queryBlock,EiConstant.resultBlock,EiConstant.resultBlock,"resultCount");
//EiInfo eiInfo = super.query(inInfo, HPSB003A.DETAIL_QUERY, new HPSB003A(), false, new EiBlockMeta(), EiConstant.queryBlock, CommonConstant.Field.DETAIL, CommonConstant.Field.DETAIL, "HPSB003A.detailCount");
//inInfo.setBlock(eiInfo.getBlock(CommonConstant.Field.DETAIL));
CommonMethod.initBlock(inInfo,
Arrays.asList(
DdynamicEnum.FACTORY_CODE_BOX_BLOCK_ID,
DdynamicEnum.USER_BLOCK_ID,
DdynamicEnum.GROUP_CODE_BOX_BLOCK_ID),null
);
return inInfo;
}
@Override
public EiInfo query(EiInfo inInfo) {
EiBlock block = inInfo.getBlock(EiConstant.queryBlock);
block.setCell(ACConstants.ROW_CODE_0, HPSB003.FIELD_DELETE_FLAG, CommonConstant.YesNo.NO_0);
inInfo = super.query(inInfo, HPSB003A.RESULT_QUERY, new HPSB003A(),false, new EiBlockMeta(),EiConstant.queryBlock,EiConstant.resultBlock,EiConstant.resultBlock,HPSB003A.RESULT_COUNT);
//queryDetail(inInfo);
return inInfo;
}
/**
* 设备保养
* @param inInfo 参数对象
*/
public EiInfo queryDetail (EiInfo inInfo){
EiBlock block = inInfo.getBlock(EiConstant.queryBlock);
block.setCell(ACConstants.ROW_CODE_0, HPSB003.FIELD_DELETE_FLAG, CommonConstant.YesNo.NO_0);
return super.query(inInfo, HPSB003A.DETAIL_QUERY, new HPSB003A(), false, new EiBlockMeta(), EiConstant.queryBlock, CommonConstant.Field.DETAIL, CommonConstant.Field.DETAIL, HPSB003A.DETAIL_COUNT);
}
/**
* 设备保养
* @param inInfo 参数对象
*/
public EiInfo queryDetail1 (EiInfo inInfo){
EiBlock block = inInfo.getBlock(EiConstant.queryBlock);
block.setCell(ACConstants.ROW_CODE_0, HPSB003.FIELD_DELETE_FLAG, CommonConstant.YesNo.NO_0);
return super.query(inInfo, HPSB003A.DETAIL1_QUERY, new HPSB008(), false, new EiBlockMeta(), EiConstant.queryBlock, CommonConstant.Field.DETAIL1, CommonConstant.Field.DETAIL1, HPSB003A.DETAIL1_COUNT);
}
}
package com.baosight.hpjx.hp.sb.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoBase;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.sb.domain.HPSB003;
import com.baosight.hpjx.hp.sb.domain.HPSB004;
import com.baosight.hpjx.hp.sb.domain.HPSB004A;
import com.baosight.hpjx.hp.sb.tools.HPSBTools;
import com.baosight.hpjx.util.*;
import com.baosight.hpjx.util.contants.ACConstants;
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.exception.PlatException;
import com.baosight.iplat4j.core.resource.I18nMessages;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author LiuYang
* @version 1.0 2024/8/12
* @description 设备计划
*/
public class ServiceHPSB004 extends ServiceEPBase {
@Override
public EiInfo initLoad(EiInfo inInfo) {
EiInfo outInfo = super.initLoad(inInfo,new HPSB004());
try {
CommonMethod.initBlock(outInfo,
Arrays.asList(DdynamicEnum.FACTORY_CODE_BOX_BLOCK_ID,DdynamicEnum.GROUP_CODE_BOX_BLOCK_ID,DdynamicEnum.USER_ID_BOX_BLOCK_ID),
new HashMap<String,Object>(){}
);
}catch (Exception e){
LogUtils.setDetailMsg(inInfo,e,"初始化失败");
}
return outInfo;
}
@Override
public EiInfo query(EiInfo inInfo) {
EiBlock block = inInfo.getBlock(EiConstant.queryBlock);
block.setCell(ACConstants.ROW_CODE_0, HPSB004.FIELD_DELETE_FLAG, CommonConstant.YesNo.NO_0);
String planDate = block.getCellStr(ACConstants.ROW_CODE_0,HPSB004.FIELD_PLAN_DATE);
String planStartDate = block.getCellStr(ACConstants.ROW_CODE_0,HPSB004.FIELD_PLAN_START_DATE);
String planEndDate = block.getCellStr(ACConstants.ROW_CODE_0,HPSB004.FIELD_PLAN_END_DATE);
if (!planDate.isEmpty()) {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0,HPSB004.FIELD_PLAN_DATE, StringUtil.removeHorizontalLine(planDate));
}
if (!planStartDate.isEmpty()) {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0,HPSB004.FIELD_PLAN_START_DATE, StringUtil.removeHorizontalLine(planStartDate));
}
if (!planEndDate.isEmpty()){
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0,HPSB004.FIELD_PLAN_END_DATE, StringUtil.removeHorizontalLine(planEndDate));
}
return super.query(inInfo,HPSB004.QUERY,new HPSB004());
}
@OperationLogAnnotation(operModul = "设备计划",operType = "删除",operDesc = "删除操作")
@Override
public EiInfo delete(EiInfo inInfo) {
int i = 0;
try {
HPSB004 hgsb002 = new HPSB004();
EiBlock eiBlock = inInfo.getBlock(EiConstant.resultBlock);
for (i = 0; i < eiBlock.getRowCount(); i++) {
Map<?, ?> map = eiBlock.getRow(i);
hgsb002.fromMap(map);
hgsb002.setDeleteFlag(CommonConstant.YesNo.YES_1);
AssertUtils.isTrue(hgsb002.getPlanStatus()==1,"设备计划已审批完成,无法删除!");
DaoUtils.update(HPSB004.DELETE_FLAG, hgsb002.toMap());
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsgByKey("ep.1000", new String[]{String.valueOf(i), I18nMessages.getText("label.delete", "删除")});
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "删除失败");
}
return inInfo;
}
/**
* 保存操作
*/
@OperationLogAnnotation(operModul = "设备计划",operType = "保存",operDesc = "保存操作")
public EiInfo save(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 写入数据
for (Map resultRow : resultRows) {
HPSB004 hgsb002 = new HPSB004();
hgsb002.fromMap(resultRow);
if (hgsb002.getId() == null || hgsb002.getId() == 0) {
this.add(hgsb002);
} else {
this.modify(hgsb002);
}
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
/**
* 新增操作
*/
public void add(HPSB004 hgsb002) {
//生成工序编码
hgsb002.setPlanCode(SequenceGenerator.getNextSequence(HPConstant.SequenceId.PLAN_CODE));
DaoUtils.insert(HPSB004.INSERT, hgsb002);
}
/**
* 修改操作
*/
public void modify(HPSB004 hgsb002) {
DaoUtils.update(HPSB004.UPDATE, hgsb002);
}
@OperationLogAnnotation(operModul = "设备计划",operType = "修改",operDesc = "修改状态操作")
public EiInfo updateStatus(EiInfo inInfo){
int i = 0;
try {
EiBlock eiBlock = inInfo.getBlock(EiConstant.resultBlock);
for (i = 0; i < eiBlock.getRowCount(); i++) {
Map<?, ?> map = eiBlock.getRow(i);
HPSB004 hgsb002 = new HPSB004();
hgsb002.fromMap(map);
Map<String,Object> qarma = new HashMap<>();
List list = HPSBTools.Hpsb004.getDetails(hgsb002.getId());
AssertUtils.isEmpty(list, "设备计划详情不能为空,无法审批完成!");
DaoUtils.update(HPSB004.UPDATE_STATUS, hgsb002);
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsgByKey("ep.1000", new String[]{String.valueOf(i), I18nMessages.getText("label.update", "修改")});
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "审批失败");
return inInfo;
}
return inInfo;
}
@OperationLogAnnotation(operModul = "设备计划",operType = "保存",operDesc = "定时添加设备计划")
public EiInfo autoAdd(EiInfo inInfo) {
try {
String systemDate = DateUtils.formatShort(DateUtils.date());
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0,HPSB003.FIELD_MAINTAIN_DATE,systemDate);
List<HPSB003> hgsb001s= DaoBase.getInstance().query(HPSB003.QUERY,new HashMap<String,String>(){{
put(HPSB003.FIELD_MAINTAIN_DATE,systemDate);
}});
//List<HGSB001> resultBlock = inInfo.getBlock(EiConstant.resultBlock).getRows();
Map<String,List<HPSB003>> hgsb001Map = hgsb001s.stream().collect(Collectors.groupingBy(HPSB003::getCompanyCode,Collectors.toList()));
for (Map.Entry<String, List<HPSB003>> entry : hgsb001Map.entrySet()) {
String companyCode = entry.getKey();
List<HPSB003> hgsb001List = entry.getValue();
HPSB004 hgsb002 = new HPSB004();
hgsb002.setDeleteFlag(CommonConstant.YesNo.NO_0);
hgsb002.setPlanDate(systemDate);
hgsb002.setPlanType(2);
hgsb002.setPlanStartDate(systemDate.substring(0,6)+"01");
hgsb002.setPlanEndDate(systemDate.substring(0,6)+DateUtils.getDaysOfMonth(systemDate));
hgsb002.setPlanUserId("system");
hgsb002.setPlanUserName("system");
hgsb002.setPlanStatus(0);
hgsb002.setTaskStatus(0);
this.add(hgsb002);
this.addHgsb002a(hgsb001List,hgsb002);
}
}catch (Exception e){
LogUtils.setDetailMsg(inInfo,e,"自动添加设备计划失败");
}
return inInfo;
}
public void addHgsb002a(List<HPSB003> hgsb003List, HPSB004 hpsb004) {
for (HPSB003 hgsb003: hgsb003List) {
//HGSB001 hgsb001 = new HGSB001();
//hgsb001.fromMap(map);
HPSB004A hgsb004a = new HPSB004A();
hgsb004a.setDeleteFlag(CommonConstant.YesNo.NO_0);
hgsb004a.setParentId(hpsb004.getId());
hgsb004a.setGroupCode(hgsb003.getGroupCode());
//hgsb004a.setGroupName(hgsb003.getGroupName());
hgsb004a.setDeviceType(hgsb003.getDeviceType());
hgsb004a.setDeviceCode(hgsb003.getDeviceCode());
hgsb004a.setDeviceName(hgsb003.getDeviceName());
hgsb004a.setDeviceModel(hgsb003.getDeviceModel());
DaoUtils.insert(HPSB004A.INSERT,hgsb004a);
String planCode = DateUtils.getDateOfDays(hpsb004.getPlanDate(),hgsb003.getPeriodDays(),DateUtils.DATE8_PATTERN);
hgsb003.setMaintainDate(planCode);
DaoUtils.update(HPSB003.UPDATE,hgsb003);
}
}
}
package com.baosight.hpjx.hp.sb.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.sb.domain.HPSB004;
import com.baosight.hpjx.hp.sb.domain.HPSB004A;
import com.baosight.hpjx.hp.sb.tools.HPSBTools;
import com.baosight.hpjx.util.AssertUtils;
import com.baosight.hpjx.util.CommonMethod;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.contants.ACConstants;
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.exception.PlatException;
import com.baosight.iplat4j.core.resource.I18nMessages;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author LiuYang
* @version 1.0 2024/8/12
* @description 设备计划详情
*/
public class ServiceHPSB004A extends ServiceEPBase {
@Override
public EiInfo initLoad(EiInfo inInfo) {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HPSB004A.FIELD_DELETE_FLAG, CommonConstant.YesNo.NO_0);
String factoryCode = inInfo.getCellStr(EiConstant.queryBlock, ACConstants.ROW_CODE_0,HPSB004.FIELD_FACTORY_CODE);
inInfo = super.query(inInfo, HPSB004A.QUERY, new HPSB004A());
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.FACTORY_CODE_BOX_BLOCK_ID,DdynamicEnum.GROUP_CODE_BOX_BLOCK_ID), null);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.DEVICE_CODE_BOX_BLOCK_ID),
new HashMap<String,Object>(){{
put(HPSB004.FIELD_FACTORY_CODE, factoryCode);
put(HPSB004A.FIELD_DELETE_FLAG, CommonConstant.YesNo.NO_0);}}
);
return inInfo;
}
@Override
public EiInfo query(EiInfo inInfo) {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0,HPSB004A.FIELD_DELETE_FLAG, CommonConstant.YesNo.NO_0);
return super.query(inInfo, HPSB004A.QUERY,new HPSB004A());
}
@OperationLogAnnotation(operModul = "设备计划详情",operType = "删除",operDesc = "删除操作")
@Override
public EiInfo delete(EiInfo inInfo) {
int i = 0;
try {
Long parentId = Long.valueOf(inInfo.getCellStr(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HPSB004A.FIELD_PARENT_ID));
HPSB004 hgsb002 = HPSBTools.Hpsb004.get(parentId);
if (hgsb002.getPlanStatus().equals(CommonConstant.PlanStatus.UN_PLAN)){
throw new PlatException("设备计划审批已完成,无法删除");
}
HPSB004A hgsb002a = new HPSB004A();
EiBlock eiBlock = inInfo.getBlock(EiConstant.resultBlock);
for (i = 0; i < eiBlock.getRowCount(); i++) {
Map<?, ?> map = eiBlock.getRow(i);
hgsb002a.fromMap(map);
hgsb002a.setDeleteFlag(CommonConstant.YesNo.YES_1);
DaoUtils.update(HPSB004A.DELETE_FLAG, hgsb002a.toMap());
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsgByKey("ep.1000", new String[]{String.valueOf(i), I18nMessages.getText("label.delete", "删除")});
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "删除失败");
return inInfo;
}
return inInfo;
}
@OperationLogAnnotation(operModul = "设备计划详情",operType = "保存",operDesc = "保存操作")
public EiInfo save(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
Long parentId = Long.valueOf(inInfo.getCellStr(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HPSB004A.FIELD_PARENT_ID));
HPSB004 hgsb004 = HPSBTools.Hpsb004.get(parentId);
List<HPSB004A> hgsb004aList = HPSBTools.Hpsb004.getDetails(parentId);
// 写入数据
for (Map resultRow : resultRows) {
HPSB004A hgsb002a = new HPSB004A();
hgsb002a.fromMap(resultRow);
// 状态==1抛出异常
if (hgsb004.getPlanStatus()==1) {
throw new PlatException("设备计划已审批完成,保存失败!");
}
if (hgsb002a.getId() == null || hgsb002a.getId() == 0) {
List<HPSB004A> hgsb002aList = hgsb004aList.stream().filter(hgsb002a1 ->
hgsb002a1.getDeviceCode().equals(hgsb002a.getDeviceCode())
&&hgsb002a1.getGroupCode().equals(hgsb002a.getGroupCode())).collect(Collectors.toList());
AssertUtils.isNotEmpty(hgsb002aList, "无法重复添加!");
hgsb002a.setParentId(parentId);
this.add(hgsb002a);
} else {
this.modify(hgsb002a);
}
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
/**
* 新增操作
*/
public void add(HPSB004A hgsb002a) {
DaoUtils.insert(HPSB004A.INSERT, hgsb002a);
}
/**
* 修改操作
*/
public void modify(HPSB004A hgsb002a) {
DaoUtils.update(HPSB004A.UPDATE, hgsb002a);
}
}
package com.baosight.hpjx.hp.sb.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.sb.domain.HPSB005;
import com.baosight.hpjx.util.CommonMethod;
import com.baosight.hpjx.util.EiInfoUtils;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.StringUtil;
import com.baosight.hpjx.util.contants.ACConstants;
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.exception.PlatException;
import com.baosight.iplat4j.core.resource.I18nMessages;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author LiuYang
* @version 1.0 2024/8/12
* @description 设备维修
*/
public class ServiceHPSB005 extends ServiceEPBase {
@Override
public EiInfo initLoad(EiInfo inInfo) {
EiInfo outInfo = super.initLoad(inInfo,new HPSB005());
try {
Map<String,Object> qarma = new HashMap<>();
//EiInfoUtils.addBlock(outInfo,"roleCompany", UserSessionUtils.getRoleCompany(), Company.class);
//角色公司
//List<String> roleCompanyCode = HGSBTools.getRoleCompanyCode();
//qarma.put(HGSB001.FIELD_COMPANY_CODES,roleCompanyCode);
CommonMethod.initBlock(outInfo, Arrays.asList(DdynamicEnum.USER_ID_BOX_BLOCK_ID),qarma);
CommonMethod.initBlock(outInfo, Arrays.asList(DdynamicEnum.FACTORY_CODE_BOX_BLOCK_ID,DdynamicEnum.DEVICE_CODE_BOX_BLOCK_ID),null);
}catch (Exception e){
LogUtils.setDetailMsg(outInfo,e,"初始化失败");
}
return outInfo;
}
@Override
public EiInfo query(EiInfo inInfo) {
EiBlock block = inInfo.getBlock(EiConstant.queryBlock);
block.setCell(ACConstants.ROW_CODE_0, HPSB005.FIELD_DELETE_FLAG, CommonConstant.YesNo.NO_0);
String applyDate = block.getCellStr(ACConstants.ROW_CODE_0,HPSB005.FIELD_APPLY_DATE);
if (!applyDate.isEmpty()) {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0,HPSB005.FIELD_APPLY_DATE, StringUtil.removeHorizontalLine(applyDate));
}
return super.query(inInfo,HPSB005.QUERY,new HPSB005());
}
@OperationLogAnnotation(operModul = "设备维修申请",operType = "删除",operDesc = "删除操作")
@Override
public EiInfo delete(EiInfo inInfo) {
int i = 0;
try {
HPSB005 hgsb003 = new HPSB005();
EiBlock eiBlock = inInfo.getBlock(EiConstant.resultBlock);
for (i = 0; i < eiBlock.getRowCount(); i++) {
Map<?, ?> map = eiBlock.getRow(i);
hgsb003.fromMap(map);
hgsb003.setDeleteFlag(CommonConstant.YesNo.YES_1);
if (hgsb003.getStatus().equals(CommonConstant.PlanStatus.UN_PLAN)){
throw new PlatException("维保申请审批完成,无法删除");
}
DaoUtils.update(HPSB005.DELETE_FLAG, hgsb003.toMap());
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsgByKey("ep.1000", new String[]{String.valueOf(i), I18nMessages.getText("label.delete", "删除")});
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "删除失败");
}
return inInfo;
}
/**
* 保存操作
*/
@OperationLogAnnotation(operModul = "设备维修申请",operType = "保存",operDesc = "保存操作")
public EiInfo save(EiInfo inInfo) {
int i = 0;
try {
EiBlock eiBlock = inInfo.getBlock(EiConstant.resultBlock);
// 写入数据
for (i = 0; i < eiBlock.getRowCount(); i++) {
Map<?, ?> map = eiBlock.getRow(i);
HPSB005 hpsb005 = new HPSB005();
hpsb005.fromMap(map);
if (hpsb005.getId() == null || hpsb005.getId() == 0) {
this.add(hpsb005);
} else {
this.modify(hpsb005);
}
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + eiBlock.getRowCount() + "]条数据保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
/**
* 新增操作
*/
public void add(HPSB005 hpsb005) {
//生成申请单号
hpsb005.setApplyCode(SequenceGenerator.getNextSequence(HPConstant.SequenceId.APPLY_CODE));
DaoUtils.insert(HPSB005.INSERT, hpsb005);
}
/**
* 修改操作
*/
public void modify(HPSB005 hpsb005) {
DaoUtils.update(HPSB005.UPDATE, hpsb005);
}
@OperationLogAnnotation(operModul = "设备申请维修",operType = "修改",operDesc = "修改状态操作")
public EiInfo updateStatus(EiInfo inInfo){
int i = 0;
try {
HPSB005 hgsb003 = new HPSB005();
EiBlock eiBlock = inInfo.getBlock(EiConstant.resultBlock);
for (i = 0; i < eiBlock.getRowCount(); i++) {
Map<?, ?> map = eiBlock.getRow(i);
hgsb003.fromMap(map);
DaoUtils.update(HPSB005.UPDATE_STATUS, hgsb003);
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsgByKey("ep.1000", new String[]{String.valueOf(i), I18nMessages.getText("label.update", "修改")});
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "修改失败");
}
return inInfo;
}
@OperationLogAnnotation(operModul = "设备申请维修",operType = "上传附件",operDesc = "上传附件操作")
public EiInfo updateDocId(EiInfo inInfo){
int i = 0;
try {
HPSB005 hgsb003 = new HPSB005();
EiBlock eiBlock = inInfo.getBlock(EiConstant.resultBlock);
for (i = 0; i < eiBlock.getRowCount(); i++) {
Map<?, ?> map = eiBlock.getRow(i);
hgsb003.fromMap(map);
DaoUtils.update(HPSB005.UPDATE_DOC_ID, hgsb003);
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsgByKey("ep.1000", new String[]{String.valueOf(i), I18nMessages.getText("label.update", "修改")});
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "上传失败");
}
return inInfo;
}
}
package com.baosight.hpjx.hp.sb.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
/**
* @author LiuYang
* @version 1.0 2024/8/13
* @description 附件上传
*/
public class ServiceHPSB005A extends ServiceEPBase {
/**
* 画面初始化.
*/
@OperationLogAnnotation(operModul = "附件上传",operType = "查询",operDesc = "初始化")
@Override
public EiInfo initLoad(EiInfo inInfo) {
return inInfo;
}
/**
* 附件上传.
*/
@OperationLogAnnotation(operModul = "附件上传",operType = "上传",operDesc = "附件上传")
public EiInfo form(EiInfo inInfo) {
return inInfo;
}
}
package com.baosight.hpjx.hp.sb.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoBase;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.sb.domain.HPSB004;
import com.baosight.hpjx.hp.sb.domain.HPSB006;
import com.baosight.hpjx.util.CommonMethod;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.StringUtil;
import com.baosight.hpjx.util.contants.ACConstants;
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.exception.PlatException;
import com.baosight.iplat4j.core.resource.I18nMessages;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author LiuYang
* @version 1.0 2024/8/12
* @description 设备点检
*/
public class ServiceHPSB006 extends ServiceEPBase {
@Override
public EiInfo initLoad(EiInfo inInfo) {
EiInfo outInfo = super.initLoad(inInfo,new HPSB006());
try {
Map<String,Object> qarma = new HashMap<>();
//EiInfoUtils.addBlock(outInfo,"roleCompany", UserSessionUtils.getRoleCompany(), Company.class);
//List<String> roleCompanyCode = HGSBTools.getRoleCompanyCode();
//qarma.put(HGSB001.FIELD_COMPANY_CODES,roleCompanyCode);
CommonMethod.initBlock(outInfo, Arrays.asList(DdynamicEnum.FACTORY_CODE_BOX_BLOCK_ID,DdynamicEnum.USER_ID_BOX_BLOCK_ID),qarma);
}catch (Exception e){
LogUtils.setDetailMsg(inInfo,e,"初始化失败");
}
return outInfo;
}
@Override
public EiInfo query(EiInfo inInfo) {
EiBlock block = inInfo.getBlock(EiConstant.queryBlock);
block.setCell(ACConstants.ROW_CODE_0, HPSB006.FIELD_DELETE_FLAG, CommonConstant.YesNo.NO_0);
String planDate = block.getCellStr(ACConstants.ROW_CODE_0,HPSB006.FIELD_INSPEC_DATE);
if (!planDate.isEmpty()) {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0,HPSB006.FIELD_INSPEC_DATE, StringUtil.removeHorizontalLine(planDate));
}
return super.query(inInfo,HPSB006.QUERY,new HPSB006());
}
@OperationLogAnnotation(operModul = "设备点检",operType = "删除",operDesc = "删除操作")
@Override
public EiInfo delete(EiInfo inInfo) {
int i = 0;
try {
HPSB006 hgsb004 = new HPSB006();
EiBlock eiBlock = inInfo.getBlock(EiConstant.resultBlock);
for (i = 0; i < eiBlock.getRowCount(); i++) {
Map<?, ?> map = eiBlock.getRow(i);
hgsb004.fromMap(map);
hgsb004.setDeleteFlag(CommonConstant.YesNo.YES_1);
if (hgsb004.getCheckStatus()==1) {
String str = "设备点检已审批完成,无法删除!";
throw new PlatException(str);
}
Map map1 = new HashMap<>();
map1.put(HPSB004.FIELD_COMPANY_CODE,hgsb004.getCompanyCode());
map1.put(HPSB004.FIELD_PLAN_CODE,hgsb004.getPlanCode());
map1.put(HPSB004.FIELD_PLAN_START_DATE,hgsb004.getPlanStartDate());
map1.put(HPSB004.FIELD_PLAN_END_DATE,hgsb004.getPlanEndDate());
map1.put(HPSB004.FIELD_PLAN_TYPE,1);
List<HPSB004> list = DaoBase.getInstance().query(HPSB004.QUERY, map1);
for (HPSB004 hpsb004 : list){
hpsb004.setTaskStatus(0);
DaoUtils.update(HPSB004.UPDATE, hpsb004);
}
DaoUtils.update(HPSB004.DELETE_FLAG, hgsb004.toMap());
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsgByKey("ep.1000", new String[]{String.valueOf(i), I18nMessages.getText("label.delete", "删除")});
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "删除失败");
}
return inInfo;
}
/**
* 保存操作
*/
@OperationLogAnnotation(operModul = "设备点检",operType = "保存",operDesc = "保存操作")
public EiInfo save(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 写入数据
for (int i = 0; i < resultRows.size(); i++) {
HPSB006 hgsb004 = new HPSB006();
hgsb004.fromMap(resultRows.get(i));
if (hgsb004.getId() == null || hgsb004.getId() == 0) {
this.add(hgsb004);
} else {
this.modify(hgsb004);
}
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
/**
* 新增操作
*/
public void add(HPSB006 hgsb004) {
//生成点检单号
hgsb004.setInspecCode(SequenceGenerator.getNextSequence(HPConstant.SequenceId.INSPEC_CODE));
DaoUtils.insert(HPSB006.INSERT, hgsb004);
}
/**
* 修改操作
*/
public void modify(HPSB006 hgsb004) {
hgsb004.setInspecDate(StringUtil.removeHorizontalLine(hgsb004.getInspecDate()));
DaoUtils.update(HPSB006.UPDATE, hgsb004);
}
@OperationLogAnnotation(operModul = "设备点检",operType = "修改",operDesc = "修改状态操作")
public EiInfo updateStatus(EiInfo inInfo){
int i = 0;
try {
HPSB006 hgsb004 = new HPSB006();
EiBlock eiBlock = inInfo.getBlock(EiConstant.resultBlock);
for (i = 0; i < eiBlock.getRowCount(); i++) {
Map<?, ?> map = eiBlock.getRow(i);
hgsb004.fromMap(map);
DaoUtils.update(HPSB006.UPDATE_STATUS, hgsb004);
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsgByKey("ep.1000", new String[]{String.valueOf(i), I18nMessages.getText("label.update", "修改")});
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "修改失败");
}
return inInfo;
}
}
package com.baosight.hpjx.hp.sb.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.sb.domain.HPSB004A;
import com.baosight.hpjx.hp.sb.domain.HPSB006;
import com.baosight.hpjx.hp.sb.domain.HPSB006A;
import com.baosight.hpjx.hp.sb.domain.HPSB007;
import com.baosight.hpjx.hp.sb.tools.HPSBTools;
import com.baosight.hpjx.util.CommonMethod;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.contants.ACConstants;
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.exception.PlatException;
import com.baosight.iplat4j.core.resource.I18nMessages;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author LiuYang
* @version 1.0 2024/8/12
* @description 设备点检详情
*/
public class ServiceHPSB006A extends ServiceEPBase {
@Override
public EiInfo initLoad(EiInfo inInfo) {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HPSB006A.FIELD_DELETE_FLAG, CommonConstant.YesNo.NO_0);
String factoryCode = inInfo.getCellStr(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HPSB006.FIELD_FACTORY_CODE);
//String groupCode = inInfo.getCellStr(EiConstant.queryBlock, ACConstants.ROW_CODE_0,HPSB006A.FIELD_GROUP_CODE);
inInfo = super.query(inInfo, HPSB006A.QUERY, new HPSB006A());
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.FACTORY_CODE_BOX_BLOCK_ID),null);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.DEVICE_CODE_BOX_BLOCK_ID),
new HashMap<String,Object>(){{
put(HPSB006.FIELD_FACTORY_CODE,factoryCode);
//put(HPSB006A.FIELD_GROUP_CODE,groupCode);
put(HPSB006A.FIELD_DELETE_FLAG,CommonConstant.YesNo.NO_0);}}
);
return inInfo;
}
@Override
public EiInfo query(EiInfo inInfo) {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0,HPSB006A.FIELD_DELETE_FLAG, CommonConstant.YesNo.NO_0);
return super.query(inInfo, HPSB006A.QUERY,new HPSB006A());
}
@OperationLogAnnotation(operModul = "设备点检详情",operType = "删除",operDesc = "删除操作")
@Override
public EiInfo delete(EiInfo inInfo) {
int i = 0;
try {
Long parentId = Long.valueOf(inInfo.getCellStr(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HPSB004A.FIELD_PARENT_ID));
HPSB006 hgsb004 = HPSBTools.Hpsb006.getId(parentId);
if (hgsb004.getCheckStatus().equals(CommonConstant.PlanStatus.UN_PLAN)){
throw new PlatException("设备点检审批完成,无法删除");
}
HPSB006A hgsb004a = new HPSB006A();
EiBlock eiBlock = inInfo.getBlock(EiConstant.resultBlock);
for (i = 0; i < eiBlock.getRowCount(); i++) {
Map<?, ?> map = eiBlock.getRow(i);
hgsb004a.fromMap(map);
hgsb004a.setDeleteFlag(CommonConstant.YesNo.YES_1);
DaoUtils.update(HPSB006A.DELETE_FLAG, hgsb004a.toMap());
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsgByKey("ep.1000", new String[]{String.valueOf(i), I18nMessages.getText("label.delete", "删除")});
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "删除失败");
}
return inInfo;
}
@OperationLogAnnotation(operModul = "设备点检详情",operType = "保存",operDesc = "保存操作")
public EiInfo save(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 写入数据
for (int i = 0; i < resultRows.size(); i++) {
HPSB006A hgsb004a = new HPSB006A();
hgsb004a.fromMap(resultRows.get(i));
if (hgsb004a.getId() == null || hgsb004a.getId() == 0) {
hgsb004a.setParentId(Long.valueOf(inInfo.getCellStr(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HPSB006A.FIELD_PARENT_ID)));
this.add(hgsb004a);
} else {
this.modify(hgsb004a);
}
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
/**
* 新增操作
*/
public void add(HPSB006A hgsb004a) {
DaoUtils.insert(HPSB006A.INSERT, hgsb004a);
}
/**
* 修改操作
*/
public void modify(HPSB006A hgsb004a) {
DaoUtils.update(HPSB006A.UPDATE, hgsb004a);
}
@OperationLogAnnotation(operModul = "设备点检详情",operType = "上传附件",operDesc = "上传附件操作")
public EiInfo updateDocId(EiInfo inInfo){
int i = 0;
try {
HPSB006A hgsb004a = new HPSB006A();
EiBlock eiBlock = inInfo.getBlock(EiConstant.resultBlock);
for (i = 0; i < eiBlock.getRowCount(); i++) {
Map<?, ?> map = eiBlock.getRow(i);
hgsb004a.fromMap(map);
DaoUtils.update(HPSB006A.UPDATE_DOC_ID, hgsb004a);
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsgByKey("ep.1000", new String[]{String.valueOf(i), I18nMessages.getText("label.update", "修改")});
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "上传失败");
}
return inInfo;
}
}
package com.baosight.hpjx.hp.sb.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.sb.domain.*;
import com.baosight.hpjx.hp.sb.tools.HPSBTools;
import com.baosight.hpjx.util.*;
import com.baosight.hpjx.util.contants.ACConstants;
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.ServiceEPBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author LiuYang
* @version 1.0 2024/8/13
* @description 设备点检
*/
public class ServiceHPSB006B extends ServiceEPBase {
@Override
public EiInfo initLoad(EiInfo inInfo) {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HPSB004.FIELD_DELETE_FLAG, CommonConstant.YesNo.NO_0);
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HPSB004.FIELD_TASK_STATUS, CommonConstant.YesNo.NO_0);
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HPSB004.FIELD_PLAN_STATUS, CommonConstant.YesNo.YES_1);
inInfo = super.query(inInfo, HPSB004.QUERY, new HPSB004());
try {
Map<String,Object> qarma = new HashMap<>();
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.FACTORY_CODE_BOX_BLOCK_ID,DdynamicEnum.GROUP_RECORD_BLOCK_ID),qarma);
//EiInfoUtils.addBlock(inInfo,"roleCompany", UserSessionUtils.getRoleCompany(), Company.class);
//List<String> roleCompanyCode = HGSBTools.getRoleCompanyCode();
//qarma.put(HGSB001.FIELD_COMPANY_CODES,roleCompanyCode);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.USER_ID_BOX_BLOCK_ID),qarma);
}catch (Exception e){
LogUtils.setDetailMsg(inInfo,e,"初始化失败");
}
return inInfo;
}
@Override
public EiInfo query(EiInfo inInfo) {
EiBlock block = inInfo.getBlock(EiConstant.queryBlock);
block.setCell(ACConstants.ROW_CODE_0, HPSB004.FIELD_DELETE_FLAG, CommonConstant.YesNo.NO_0);
String planDate = block.getCellStr(ACConstants.ROW_CODE_0, HPSB004.FIELD_PLAN_DATE);
if (!planDate.isEmpty()) {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0,HPSB004.FIELD_PLAN_DATE, StringUtil.removeHorizontalLine(planDate));
}
return super.query(inInfo,HPSB004.QUERY,new HPSB004());
}
/**
* 保存操作
*/
@OperationLogAnnotation(operModul = "设备计划",operType = "保存",operDesc = "保存操作")
public EiInfo save(EiInfo inInfo) {
try {
EiBlock block =inInfo.getBlock(EiConstant.queryBlock);
String pageNumber = block.getCellStr(ACConstants.ROW_CODE_0,"pageNumber");
Map<String,String> map = new HashMap<String,String>();
map.put(HPSB006.FIELD_INSPEC_USER_ID,block.getCellStr(ACConstants.ROW_CODE_0,HPSB006.FIELD_INSPEC_USER_ID));
map.put(HPSB006.FIELD_INSPEC_USER_NAME,block.getCellStr(ACConstants.ROW_CODE_0,HPSB006.FIELD_INSPEC_USER_NAME));
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
List<HPSB004A> hpsb004A;
// 写入数据
for (Map resultRow : resultRows) {
HPSB004 hpsb004 = new HPSB004();
hpsb004.fromMap(resultRow);
if ("HPSB006".equals(pageNumber)) {
//添加设备点检
HPSB006 hpsb006 = addHgsb004(hpsb004,map);
hpsb004A = HPSBTools.Hpsb004.getDetails(hpsb004.getId());
addHgsb004a(hpsb004A,hpsb006.getId());
}else if ("HPSB007".equals(pageNumber)){
//添加设备保养
HPSB007 hpsb007 = addHgsb005(hpsb004,map);
hpsb004A = HPSBTools.Hpsb004.getDetails(hpsb004.getId());
addHgsb005a(hpsb004A,hpsb007.getId());
//修改保养日期
updateMaintainDate(hpsb004A,hpsb004);
}
hpsb004.setTaskStatus(1);
DaoUtils.update(HPSB004.UPDATE,hpsb004);
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
/**
* 添加设备点检
*/
private HPSB006 addHgsb004(HPSB004 hgsb002,Map<String,String> map){
HPSB006 hpsb006 = new HPSB006();
hpsb006.setCompanyCode(hgsb002.getCompanyCode());
hpsb006.setFactoryCode(hgsb002.getFactoryCode());
hpsb006.setPlanCode(hgsb002.getPlanCode());
hpsb006.setPlanStartDate(hgsb002.getPlanStartDate());
hpsb006.setPlanEndDate(hgsb002.getPlanEndDate());
hpsb006.setInspecDate(DateUtils.formatShort(DateUtils.date()));
hpsb006.setInspecCode(SequenceGenerator.getNextSequence(HPConstant.SequenceId.INSPEC_CODE));
hpsb006.setInspecUserId(map.get(HPSB006.FIELD_INSPEC_USER_ID));
hpsb006.setInspecUserName(map.get(HPSB006.FIELD_INSPEC_USER_NAME));
DaoUtils.insert(HPSB006.INSERT, hpsb006);
Map map1 = hpsb006.toMap();
map1.remove(HPSB006.FIELD_ID);
List<HPSB006> hgsb004List = this.dao.query(HPSB006.QUERY,map1);
AssertUtils.isEmpty(hgsb004List, "设备点检添加失败");
return hgsb004List.get(0);
}
/**
* 添加设备点检
*/
private void addHgsb004a(List<HPSB004A> hpsb004AList, Long id){
AssertUtils.isEmpty(hpsb004AList, "设备计划详情不能为空");
for (HPSB004A hpsb004a: hpsb004AList) {
HPSB006A hpsb006A = new HPSB006A();
hpsb006A.setCheckItem(hpsb004a.getCheckItem());
hpsb006A.setCheckDescrip(hpsb004a.getCheckDescrip());
hpsb006A.setDeviceCode(hpsb004a.getDeviceCode());
hpsb006A.setDeviceName(hpsb004a.getDeviceName());
hpsb006A.setDeleteFlag(CommonConstant.YesNo.NO_0);
hpsb006A.setGroupCode(hpsb004a.getGroupCode());
hpsb006A.setGroupName(hpsb004a.getGroupName());
hpsb006A.setDeviceType(hpsb004a.getDeviceType());
hpsb006A.setParentId(id);
DaoUtils.insert(HPSB006A.INSERT, hpsb006A);
}
}
/**
* 添加设备保养
*/
private HPSB007 addHgsb005(HPSB004 hpsb004,Map<String,String> map){
HPSB007 hpsb007 = new HPSB007();
hpsb007.setCompanyCode(hpsb004.getCompanyCode());
hpsb007.setFactoryCode(hpsb004.getFactoryCode());
hpsb007.setPlanCode(hpsb004.getPlanCode());
hpsb007.setPlanStartDate(hpsb004.getPlanStartDate());
hpsb007.setPlanEndDate(hpsb004.getPlanEndDate());
hpsb007.setUpkeepDate(DateUtils.formatShort(DateUtils.date()));
hpsb007.setUpkeepCode(SequenceGenerator.getNextSequence(HPConstant.SequenceId.INSPEC_CODE));
hpsb007.setUpkeepUserId(map.get(HPSB006.FIELD_INSPEC_USER_ID));
hpsb007.setUpkeepUserName(map.get(HPSB006.FIELD_INSPEC_USER_NAME));
DaoUtils.insert(HPSB007.INSERT, hpsb007);
Map map1 = hpsb007.toMap();
map1.remove(HPSB006.FIELD_ID);
List<HPSB007> hgsb005List = this.dao.query(HPSB007.QUERY,map1);
AssertUtils.isEmpty(hgsb005List, "设备保养添加失败");
return hgsb005List.get(0);
}
/**
* 添加设备保养详情
*/
private void addHgsb005a(List<HPSB004A> hpsb004aList,Long id){
AssertUtils.isEmpty(hpsb004aList, "设备计划详情不能为空");
for (HPSB004A hgsb002a: hpsb004aList) {
HPSB007A hpsb007A = new HPSB007A();
hpsb007A.setCheckItem(hgsb002a.getCheckItem());
hpsb007A.setCheckDescrip(hgsb002a.getCheckDescrip());
hpsb007A.setDeviceCode(hgsb002a.getDeviceCode());
hpsb007A.setDeviceName(hgsb002a.getDeviceName());
hpsb007A.setDeleteFlag(CommonConstant.YesNo.NO_0);
hpsb007A.setGroupCode(hgsb002a.getGroupCode());
hpsb007A.setGroupName(hgsb002a.getGroupName());
hpsb007A.setDeviceType(hgsb002a.getDeviceType());
hpsb007A.setParentId(id);
DaoUtils.insert(HPSB007A.INSERT, hpsb007A);
}
}
/**
* 修改保养日期
*/
private void updateMaintainDate(List<HPSB004A> hpsb004aList, HPSB004 hpsb004){
for (HPSB004A hpsb004a: hpsb004aList) {
HPSB003 hpsb003 = new HPSB003();
hpsb003.fromMap(hpsb004a.toMap());
hpsb003.setCompanyCode(hpsb004.getCompanyCode());
hpsb003.setMaintainDate(DateUtils.formatShort(DateUtils.date()));
DaoUtils.update(HPSB003.UPDATE_MAINTAIN_DATE,hpsb003);
}
}
}
package com.baosight.hpjx.hp.sb.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoBase;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.sb.domain.HPSB004;
import com.baosight.hpjx.hp.sb.domain.HPSB007;
import com.baosight.hpjx.util.CommonMethod;
import com.baosight.hpjx.util.DateUtils;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.StringUtil;
import com.baosight.hpjx.util.contants.ACConstants;
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.exception.PlatException;
import com.baosight.iplat4j.core.resource.I18nMessages;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author LiuYang
* @version 1.0 2024/8/12
* @description 设备保养
*/
public class ServiceHPSB007 extends ServiceEPBase {
@Override
public EiInfo initLoad(EiInfo inInfo) {
EiInfo outInfo = super.initLoad(inInfo,new HPSB007());
try {
Map<String,Object> qarma = new HashMap<>();
//EiInfoUtils.addBlock(outInfo,"roleCompany", UserSessionUtils.getRoleCompany(), Company.class);
CommonMethod.initBlock(outInfo, Arrays.asList(DdynamicEnum.FACTORY_CODE_BOX_BLOCK_ID,DdynamicEnum.GROUP_RECORD_BLOCK_ID), qarma);
//角色公司
//List<String> roleCompanyCode = HGSBTools.getRoleCompanyCode();
//qarma.put(HGSB001.FIELD_COMPANY_CODES,roleCompanyCode);
CommonMethod.initBlock(outInfo, Arrays.asList(DdynamicEnum.USER_ID_BOX_BLOCK_ID),qarma);
}catch (Exception e){
LogUtils.setDetailMsg(inInfo,e,"初始化失败");
}
return outInfo;
}
@Override
public EiInfo query(EiInfo inInfo) {
EiBlock block = inInfo.getBlock(EiConstant.queryBlock);
block.setCell(ACConstants.ROW_CODE_0, HPSB007.FIELD_DELETE_FLAG, CommonConstant.YesNo.NO_0);
String upkeepDate = block.getCellStr(ACConstants.ROW_CODE_0,HPSB007.FIELD_UPKEEP_DATE);
if (!upkeepDate.isEmpty()) {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0,HPSB007.FIELD_UPKEEP_DATE, StringUtil.removeHorizontalLine(upkeepDate));
}
return super.query(inInfo,HPSB007.QUERY,new HPSB007());
}
@OperationLogAnnotation(operModul = "设备保养",operType = "删除",operDesc = "删除操作")
@Override
public EiInfo delete(EiInfo inInfo) {
int i = 0;
try {
EiBlock eiBlock = inInfo.getBlock(EiConstant.resultBlock);
for (i = 0; i < eiBlock.getRowCount(); i++) {
Map<?, ?> map = eiBlock.getRow(i);
HPSB007 hpsb007 = new HPSB007();
hpsb007.fromMap(map);
hpsb007.setDeleteFlag(CommonConstant.YesNo.YES_1);
if (hpsb007.getCheckStatus()==1) {
throw new PlatException("设备保养已审批完成,无法删除!");
}
Map map1 = new HashMap<>();
map1.put(HPSB004.FIELD_COMPANY_CODE,hpsb007.getCompanyCode());
map1.put(HPSB004.FIELD_PLAN_CODE,hpsb007.getPlanCode());
map1.put(HPSB004.FIELD_PLAN_START_DATE,hpsb007.getPlanStartDate());
map1.put(HPSB004.FIELD_PLAN_END_DATE,hpsb007.getPlanEndDate());
map1.put(HPSB004.FIELD_PLAN_TYPE,2);
List<HPSB004> list = DaoBase.getInstance().query(HPSB004.QUERY, map1);
for (HPSB004 hpsb004 : list){
hpsb004.setTaskStatus(0);
DaoUtils.update(HPSB004.UPDATE, hpsb004);
}
DaoUtils.update(HPSB007.DELETE_FLAG, hpsb007.toMap());
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsgByKey("ep.1000", new String[]{String.valueOf(i), I18nMessages.getText("label.delete", "删除")});
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "删除失败");
}
return inInfo;
}
/**
* 保存操作
*/
@OperationLogAnnotation(operModul = "设备保养",operType = "保存",operDesc = "保存操作")
public EiInfo save(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 写入数据
for (Map resultRow : resultRows) {
HPSB007 hgsb005 = new HPSB007();
hgsb005.fromMap(resultRow);
if (hgsb005.getId() == null || hgsb005.getId() == 0) {
this.add(hgsb005);
} else {
this.modify(hgsb005);
}
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
/**
* 新增操作
*/
public void add(HPSB007 hgsb005) {
//生成保养单号
hgsb005.setUpkeepDate(SequenceGenerator.getNextSequence(HPConstant.SequenceId.UPKEEP_CODE));
DaoUtils.insert(HPSB007.INSERT, hgsb005);
}
/**
* 修改操作
*/
public void modify(HPSB007 hgsb005) {
hgsb005.setUpkeepDate(DateUtils.formatShort(hgsb005.getUpkeepDate()));
DaoUtils.update(HPSB007.UPDATE, hgsb005);
}
@OperationLogAnnotation(operModul = "设备保养",operType = "修改",operDesc = "修改状态操作")
public EiInfo updateStatus(EiInfo inInfo){
int i = 0;
try {
HPSB007 hpsb007 = new HPSB007();
EiBlock eiBlock = inInfo.getBlock(EiConstant.resultBlock);
for (i = 0; i < eiBlock.getRowCount(); i++) {
Map<?, ?> map = eiBlock.getRow(i);
hpsb007.fromMap(map);
DaoUtils.update(HPSB007.UPDATE_STATUS, hpsb007);
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsgByKey("ep.1000", new String[]{String.valueOf(i), I18nMessages.getText("label.update", "修改")});
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "修改失败");
}
return inInfo;
}
}
package com.baosight.hpjx.hp.sb.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.sb.domain.HPSB007;
import com.baosight.hpjx.hp.sb.domain.HPSB007A;
import com.baosight.hpjx.hp.sb.tools.HPSBTools;
import com.baosight.hpjx.util.CommonMethod;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.contants.ACConstants;
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.exception.PlatException;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author LiuYang
* @version 1.0 2024/8/12
* @description 设备保养详情
*/
public class ServiceHPSB007A extends ServiceEPBase {
@Override
public EiInfo initLoad(EiInfo inInfo) {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HPSB007A.FIELD_DELETE_FLAG, CommonConstant.YesNo.NO_0);
String factoryCode = inInfo.getCellStr(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HPSB007.FIELD_FACTORY_CODE);
//String groupCode = inInfo.getCellStr(EiConstant.queryBlock, ACConstants.ROW_CODE_0,HGSB005A.FIELD_GROUP_CODE);
inInfo = super.query(inInfo, HPSB007A.QUERY, new HPSB007A());
Map qarma = new HashMap();
/*Map userCompany = HGSBTools.getUserCompany();
if (!userCompany.isEmpty()) {
qarma.put(Org.FIELD_PARENT_ORG_ID,userCompany.get(HGSB002.FIELD_COMPANY_CODE));
}*/
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.FACTORY_CODE_BOX_BLOCK_ID,DdynamicEnum.GROUP_RECORD_BLOCK_ID),qarma);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.DEVICE_CODE_BOX_BLOCK_ID),
new HashMap<String,Object>(){{
put(HPSB007.FIELD_FACTORY_CODE,factoryCode);
//put(HGSB005A.FIELD_GROUP_CODE,groupCode);
put(HPSB007A.FIELD_DELETE_FLAG,CommonConstant.YesNo.NO_0);}}
);
return inInfo;
}
@Override
public EiInfo query(EiInfo inInfo) {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0,HPSB007A.FIELD_DELETE_FLAG, CommonConstant.YesNo.NO_0);
return super.query(inInfo, HPSB007A.QUERY,new HPSB007A());
}
@OperationLogAnnotation(operModul = "设备保养详情",operType = "删除",operDesc = "删除操作")
@Override
public EiInfo delete(EiInfo inInfo) {
int i = 0;
try {
Long parentId = Long.valueOf(inInfo.getCellStr(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HPSB007A.FIELD_PARENT_ID));
HPSB007 hgsb005 = HPSBTools.Hpsb007.getId(parentId);
if (hgsb005.getCheckStatus().equals(CommonConstant.PlanStatus.UN_PLAN)){
throw new PlatException("设备保养审批完成,无法删除");
}
EiBlock eiBlock = inInfo.getBlock(EiConstant.resultBlock);
for (i = 0; i < eiBlock.getRowCount(); i++) {
Map<?, ?> map = eiBlock.getRow(i);
HPSB007A hgsb005a = new HPSB007A();
hgsb005a.fromMap(map);
hgsb005a.setDeleteFlag(CommonConstant.YesNo.YES_1);
DaoUtils.update(HPSB007A.DELETE_FLAG, hgsb005a.toMap());
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsg("操作成功!本次对[" + eiBlock.getRowCount() + "]条数据删除成功!");
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "删除失败");
}
return inInfo;
}
@OperationLogAnnotation(operModul = "设备保养详情",operType = "保存",operDesc = "保存操作")
public EiInfo save(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 写入数据
for (Map resultRow : resultRows) {
HPSB007A hgsb005a = new HPSB007A();
hgsb005a.fromMap(resultRow);
if (hgsb005a.getId() == null || hgsb005a.getId() == 0) {
hgsb005a.setParentId(Long.valueOf(inInfo.getCellStr(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HPSB007A.FIELD_PARENT_ID)));
this.add(hgsb005a);
} else {
this.modify(hgsb005a);
}
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
/**
* 新增操作
*/
public void add(HPSB007A hpsb007a) {
DaoUtils.insert(HPSB007A.INSERT, hpsb007a);
}
/**
* 修改操作
*/
public void modify(HPSB007A hpsb007a) {
DaoUtils.update(HPSB007A.UPDATE, hpsb007a);
}
@OperationLogAnnotation(operModul = "设备保养详情",operType = "上传附件",operDesc = "上传附件操作")
public EiInfo updateDocId(EiInfo inInfo){
int i = 0;
try {
HPSB007A hpsb007a = new HPSB007A();
EiBlock eiBlock = inInfo.getBlock(EiConstant.resultBlock);
for (i = 0; i < eiBlock.getRowCount(); i++) {
Map<?, ?> map = eiBlock.getRow(i);
hpsb007a.fromMap(map);
DaoUtils.update(HPSB007A.UPDATE_DOC_ID, hpsb007a);
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsg("操作成功!本次对[" + eiBlock.getRowCount() + "]条数据修改成功!");
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "修改失败");
}
return inInfo;
}
}
package com.baosight.hpjx.hp.sb.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
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.utils.Iplat4jUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.sb.domain.HPSB003;
import com.baosight.hpjx.hp.sb.domain.HPSB008;
import com.baosight.hpjx.hp.sb.domain.HPSB099;
import com.baosight.hpjx.hp.sb.tools.HPSBTools;
import com.baosight.hpjx.util.*;
import com.baosight.hpjx.util.contants.ACConstants;
import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiBlockMeta;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import org.apache.commons.lang3.ArrayUtils;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author LiuYang
* @version 1.0 2024/8/12
* @description 安全记录
*/
public class ServiceHPSB008 extends ServiceEPBase {
@Override
public EiInfo initLoad(EiInfo inInfo) {
//拼接名称 包含逻辑删除数据
CommonMethod.initBlock(inInfo,
Arrays.asList(
DdynamicEnum.FACTORY_CODE_BOX_BLOCK_ID,
DdynamicEnum.DEVICE_CODE_BOX_BLOCK_ID,
DdynamicEnum.DEVICE_CODE_BLOCK_ID
),
new HashMap<String,Object>(){}
);
return inInfo;
}
@Override
public EiInfo query(EiInfo inInfo) {
EiBlock block = inInfo.getBlock(EiConstant.queryBlock);
if (block != null) {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HPSB003.FIELD_DELETE_FLAG, CommonConstant.YesNo.NO_0);
String recordDate = block.getCellStr(ACConstants.ROW_CODE_0,HPSB008.FIELD_RECORD_DATE);
if (!recordDate.isEmpty()) {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0,HPSB008.FIELD_RECORD_DATE, StringUtil.removeHorizontalLine(recordDate));
}
}
return super.query(inInfo,HPSB008.QUERY,new HPSB008());
}
@Override
public EiInfo delete(EiInfo inInfo) {
try {
int rowCount = inInfo.getBlock(EiConstant.resultBlock).getRowCount();
for (int i = 0; i < rowCount; i++) {
Map<?,?> rowMap = inInfo.getBlock(EiConstant.resultBlock).getRow(i);
HPSB008 hpsb008 = new HPSB008();
hpsb008.fromMap(rowMap);
this.deleteFile(hpsb008.getId().toString());
DaoUtils.update(HPSB008.DELETE, hpsb008);
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + rowCount + "]条数据保存成功!");
}catch (Exception e){
LogUtils.setDetailMsg(inInfo, e, "删除失败");
}
return inInfo;
}
@OperationLogAnnotation(operModul = "安全记录",operType = "保存",operDesc = "操作")
public EiInfo save(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 写入数据
for (Map resultRow : resultRows) {
HPSB008 hpsb008 = new HPSB008();
hpsb008.fromMap(resultRow);
if (hpsb008.getId() == null || hpsb008.getId() == 0) {
this.add(hpsb008);
} else {
this.modify(hpsb008);
}
}
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
public void add(HPSB008 hgsb002) {
//生成工序编码
hgsb002.setRecordCode(SequenceGenerator.getNextSequence(HPConstant.SequenceId.RECORD_CODE));
DaoUtils.insert(HPSB008.INSERT, hgsb002);
}
/**
* 修改操作
*/
public void modify(HPSB008 hgsb002) {
DaoUtils.update(HPSB008.UPDATE, hgsb002);
}
@OperationLogAnnotation(operModul = "安全记录", operType = "新增", operDesc = "app新增操作")
public EiInfo appSave(EiInfo inInfo) {
try{
Map resultMap = EiInfoUtils.getFirstRow(inInfo, EiConstant.resultBlock);
String docId = MapUtils.getString(resultMap, HPSB099.FIELD_DOC_ID).trim();
String docVideoId = MapUtils.getString(resultMap, HPSB099.FIELD_DOC_VIDEO_ID).trim();
String[] docIds = {};
String [] docVideoIds = {};
if (StringUtils.isNotEmpty(docId)) {
docIds = docId.split(",");
}
if (StringUtils.isNotEmpty(docVideoId)) {
docVideoIds = docVideoId.split(",");
}
HPSB008 hpsb008 = new HPSB008();
hpsb008.fromMap(resultMap);
if (hpsb008.getId() == null || hpsb008.getId() == 0) {
hpsb008.setRecordCode(SequenceGenerator.getNextSequence(HPConstant.SequenceId.RECORD_CODE));
DaoUtils.insert(HPSB008.INSERT, hpsb008);
this.addFile(hpsb008, docIds, docVideoIds);
}else {
this.modify(hpsb008);
this.modifyFile(hpsb008, docIds, docVideoIds);
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
public void deleteFile(String docId) {
List<HPSB099> hpsb099List = HPSBTools.Hpsb099.getMatId(Long.valueOf(docId));
if (hpsb099List.size() > 0) {
for (HPSB099 hpsb099 : hpsb099List) {
DaoUtils.update(HPSB099.DELETE, hpsb099);
Iplat4jUtils.deleteFileByDocId(hpsb099.getDocId());
}
}
}
public void addFile(HPSB008 hpsb008, String[] docIds, String[] docVideoIds) {
for (String docIdStr : docIds){
HPSB099 hgsc099 = new HPSB099();
hgsc099.setBizType("SBJL");
hgsc099.setDocId(docIdStr);
hgsc099.setMatId(hpsb008.getId());
DaoUtils.insert(HPSB099.INSERT, hgsc099);
}
for (String docIdStr : docVideoIds){
HPSB099 hgsc099 = new HPSB099();
hgsc099.setBizType("SBJL");
hgsc099.setDocId(docIdStr);
hgsc099.setDocVideoId(docIdStr);
hgsc099.setMatId(hpsb008.getId());
DaoUtils.insert(HPSB099.INSERT, hgsc099);
}
}
public void modifyFile(HPSB008 hpsb008, String[] docIds, String[] docVideoIds) {
List<HPSB099> hpsb099List = HPSBTools.Hpsb099.getMatId(hpsb008.getId());
for (String docIdStr : docIds){
List list = hpsb099List.stream().filter(hpsb099 -> hpsb099.getDocId().equals(docIdStr)).collect(Collectors.toList());
if (list.isEmpty()){
HPSB099 hgsc099 = new HPSB099();
hgsc099.setBizType("SBJL");
hgsc099.setDocId(docIdStr);
hgsc099.setMatId(hpsb008.getId());
DaoUtils.insert(HPSB099.INSERT, hgsc099);
}
}
for (String docVideoIdStr : docVideoIds){
List list = hpsb099List.stream().filter(hpsb099 -> hpsb099.getDocId().equals(docVideoIdStr)).collect(Collectors.toList());
if (list.isEmpty()){
HPSB099 hgsc099 = new HPSB099();
hgsc099.setBizType("SBJL");
hgsc099.setDocId(docVideoIdStr);
hgsc099.setDocVideoId(docVideoIdStr);
hgsc099.setMatId(hpsb008.getId());
DaoUtils.insert(HPSB099.INSERT, hgsc099);
}
}
for (HPSB099 hpsb099 : hpsb099List) {
if (hpsb099.getDocId().trim().length() > 0 && hpsb099.getDocVideoId().trim().length() == 0 && !ArrayUtils.contains(docIds, hpsb099.getDocId())){
DaoUtils.update(HPSB099.DELETE, hpsb099);
Iplat4jUtils.deleteFileByDocId(hpsb099.getDocId());
}
if (hpsb099.getDocVideoId().trim().length() >0 && !ArrayUtils.contains(docVideoIds, hpsb099.getDocVideoId())){
DaoUtils.update(HPSB099.DELETE, hpsb099);
Iplat4jUtils.deleteFileByDocId(hpsb099.getDocVideoId());
}
}
}
}
package com.baosight.hpjx.hp.sb.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.ds.domain.HPDS002;
import com.baosight.hpjx.hp.sb.domain.HPSB099;
import com.baosight.hpjx.util.FileUtils;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.iplat4j.core.ProjectInfo;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import com.baosight.iplat4j.core.service.soa.XServiceManager;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author LiuYang
* @version 1.0 2024/8/14
* @description 附件
*/
public class ServiceHPSB099 extends ServiceEPBase {
@Override
public EiInfo initLoad(EiInfo inInfo) {
try {
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HPSB099().eiMetadata);
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
@Override
public EiInfo query(EiInfo inInfo) {
try {
// 项目环境
String projectEnv = ProjectInfo.getProjectEnv();
if (CommonConstant.ProjectEnv.RUN.equalsIgnoreCase(projectEnv)) {
inInfo = super.query(inInfo, "HPSB099.queryRun", new HPSB099());
} else {
inInfo = super.query(inInfo, "HPSB099.queryDev", new HPSB099());
}
} catch (Throwable e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
return inInfo;
}
@OperationLogAnnotation(operModul = "设备附件详情",operType = "删除",operDesc = "删除操作")
@Override
public EiInfo delete(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
for (Map resultRow : resultRows) {
HPSB099 hgsb099 = new HPSB099();
hgsb099.fromMap(resultRow);
DaoUtils.update(HPSB099.DELETE, hgsb099);
if (!hgsb099.getDocId().isEmpty()) {
this.delectDoc(hgsb099.getDocId());
}
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据删除成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "删除失败");
}
return inInfo;
}
@OperationLogAnnotation(operModul = "设备附件详情",operType = "新增",operDesc = "新增操作")
@Override
public EiInfo insert(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
for (Map resultRow : resultRows) {
HPSB099 hgsb099 = new HPSB099();
hgsb099.fromMap(resultRow);
DaoUtils.insert(HPSB099.INSERT, hgsb099);
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据新增成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "新增失败");
}
return inInfo;
}
/**
* 删除文件
* @param docId 文件ID
*/
public void delectDoc(String docId){
Map<String,Object> map = new HashMap<>();
map.put("docId",docId);
List<HPDS002> list = this.dao.query(HPDS002.QUERY,map);
if (list.size() > 0) {
String realPath = list.get(0).getRealPath();
// 项目环境
String projectEnv = ProjectInfo.getProjectEnv();
if (projectEnv.equals(CommonConstant.ProjectEnv.RUN)) {
EiInfo queryInfo = new EiInfo();
queryInfo.set(HPSB099.FIELD_DOC_ID,list.get(0).getDocId());
//获取文档信息
queryInfo.set(EiConstant.serviceId,"S_EU_0102");
EiInfo docInfo = XServiceManager.call(queryInfo);
//数据库
Map docInfoMap = docInfo.getMap("docMap");
if (docInfoMap.size() > 0) {
EiInfo eiInfo = new EiInfo();
eiInfo.set("data",docInfoMap.get("url")+"-"+0);
eiInfo.set(EiConstant.serviceId,"S_EU_0105");
//调用接口
EiInfo outInfo = XServiceManager.call(eiInfo);
if(outInfo.getStatus() == EiConstant.STATUS_FAILURE){
LogUtils.setDetailMsg(outInfo, new Throwable(), "查询部件类型失败");
outInfo.setMsg("失败");
}
}
}else {
FileUtils.deleteFile(realPath);
}
this.dao.delete(HPDS002.DELETE,map);
}
}
}
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