Commit 828739cb by wuwenlong

git change

parent 07f7066b
# Hp Smart
# hp-smart
......@@ -15,14 +15,14 @@ Already a pro? Just edit this README.md and make it your own. Want to make it ea
```
cd existing_repo
git remote add origin http://git.pseer.com/platform/hp-smart.git
git remote add origin https://gitlab.baocloud.cn/bggf/smart/hp-smart.git
git branch -M main
git push -uf origin main
```
## Integrate with your tools
- [ ] [Set up project integrations](http://git.pseer.com/platform/hp-smart/-/settings/integrations)
- [ ] [Set up project integrations](http://gitlab.baocloud.cn/bggf/smart/hp-smart/-/settings/integrations)
## Collaborate with your team
......
This diff is collapsed. Click to expand it.
package com.baosight.hpjx;
import com.baosight.iplat4j.config.ApplicationProperties;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ImportResource;
@SpringBootApplication(scanBasePackages = "com.baosight")
@ServletComponentScan("com.baosight.iplat4j.core.web.servlet")
@ImportResource(locations = {"classpath*:spring/framework/platApplicationContext*.xml","classpath*:spring/framework/applicationContext*.xml"})
@EnableConfigurationProperties({LiquibaseProperties.class, ApplicationProperties.class})
public class HpjxApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication app = new SpringApplication(HpjxApplication.class);
app.run(args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(HpjxApplication.class);
}
}
package com.baosight.hpjx.aspect;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.core.security.UserSessionUtils;
import com.baosight.hpjx.util.DateUtils;
import com.baosight.iplat4j.core.data.ibatis.dao.Dao;
import com.baosight.iplat4j.core.data.ibatis.dao.SqlMapDaoLogProxy;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.ioc.spring.PlatApplicationContext;
import com.baosight.iplat4j.core.web.threadlocal.UserSession;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
import java.sql.PreparedStatement;
import java.util.HashMap;
import java.util.Map;
/**
* 切面处理类,操作日志异常日志记录处理
*/
@Aspect //记录日志实现性能跟踪以及用户行为分析
@Component
public class OperationLogAspect {
private static Dao dao = (Dao) PlatApplicationContext.getBean("dao");
/**
* 设置操作日志切入点 记录操作日志 在注解的位置切入代码
*/
@Pointcut("@annotation(com.baosight.hpjx.aspect.annotation.OperationLogAnnotation)")
public void operLogPointCut() {
}
/**
* 设置操作异常切入点记录异常日志 扫描所有dc包下操作
*/
@Pointcut("execution(* com.baosight.hpjx.hp.*.service..*.*(..))")
public void operExceptionLogPointCut() {
}
/**
* 正常返回通知,拦截用户操作日志,连接点正常执行完成后执行, 如果连接点抛出异常,则不会执行
*
* @param joinPoint 切入点
* @param keys 返回结果
*/
@AfterReturning(value = "operLogPointCut()", returning = "keys")
public void saveOperLog(JoinPoint joinPoint, Object keys) {
// 从切面织入点处通过反射机制获取织入点处的方法
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
// 获取切入点所在的方法
Method method = signature.getMethod();
OperationLogAnnotation opLog = method.getAnnotation(OperationLogAnnotation.class);
if (opLog != null) {
try {
String companyCode;
try {
companyCode = UserSessionUtils.getCompanyCode();
} catch (Exception e) {
companyCode = "";
}
String userId = UserSession.getLoginName();
String loginName = UserSession.getLoginCName();
String operModul = opLog.operModul();
String operType = opLog.operType();
String operDesc = opLog.operDesc();
boolean saveContet = opLog.saveContent();
String sql = "INSERT INTO hpjx.SYS_OPERATION_LOG (OPER_MODUL,OPER_TYPE,OPER_DESC," +
"OPER_CONTENT,COMPANY_CODE,CREATED_BY,CREATED_NAME,CREATED_TIME)" +
" VALUES (?,?,?,?,?,?,?,?)";
PreparedStatement ps = ((SqlMapDaoLogProxy) dao).getSqlMapClient().getDataSource().getConnection().prepareStatement(sql);
ps.setString(1,operModul);
ps.setString(2,operType);
ps.setString(3,operDesc);
if(saveContet && joinPoint.getArgs() != null) {
String strBlock = EiConstant.resultBlock;
EiInfo result = ((EiInfo) joinPoint.getArgs()[0]);
ps.setString(4, JSONObject.toJSONString(((EiInfo) joinPoint.getArgs()[0]).getBlock(strBlock).getRows().get(0)));
}else {
ps.setString(4, "");
}
ps.setString(5,companyCode);
ps.setString(6,userId);
ps.setString(7,loginName);
ps.setString(8,DateUtils.shortDateTime());
ps.execute();
} catch (Exception e) {
e.printStackTrace();
}
}
}
/**
* 异常返回通知,用于拦截异常日志信息 连接点抛出异常后执行
*
* @param joinPoint 切入点
* @param e 异常信息
*/
@AfterThrowing(pointcut = "operExceptionLogPointCut()", throwing = "e")
public void saveExceptionLog(JoinPoint joinPoint, Throwable e) {
// 获取RequestAttributes
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
// 从获取RequestAttributes中获取HttpServletRequest的信息
HttpServletRequest request = (HttpServletRequest) requestAttributes
.resolveReference(RequestAttributes.REFERENCE_REQUEST);
try {
// 从切面织入点处通过反射机制获取织入点处的方法
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
// 获取切入点所在的方法
Method method = signature.getMethod();
// 获取请求的类名
String className = joinPoint.getTarget().getClass().getName();
// 获取请求的方法名
String methodName = method.getName();
methodName = className + "." + methodName;
// 请求的参数
Map<String, String> rtnMap = converMap(request.getParameterMap());
// 将参数所在的数组转换成json
String params = JSON.toJSONString(rtnMap);
// 异常信息
String errorMsg = stackTraceToString(e.getClass().getName(), e.getMessage(), e.getStackTrace());
//TODO 异常信息持久化
System.out.println(params);
System.out.println(errorMsg);
} catch (Exception e2) {
e2.printStackTrace();
}
}
/**
* 转换request 请求参数
*
* @param paramMap request获取的参数数组
*/
public Map<String, String> converMap(Map<String, String[]> paramMap) {
Map<String, String> rtnMap = new HashMap<String, String>();
for (String key : paramMap.keySet()) {
rtnMap.put(key, paramMap.get(key)[0]);
}
return rtnMap;
}
/**
* 转换异常信息为字符串
*
* @param exceptionName 异常名称
* @param exceptionMessage 异常信息
* @param elements 堆栈信息
*/
public String stackTraceToString(String exceptionName, String exceptionMessage, StackTraceElement[] elements) {
StringBuffer strbuff = new StringBuffer();
for (StackTraceElement stet : elements) {
strbuff.append(stet + "\n");
}
String message = exceptionName + ":" + exceptionMessage + "\n\t" + strbuff.toString();
return message;
}
}
\ No newline at end of file
package com.baosight.hpjx.aspect.annotation;
import java.lang.annotation.*;
/**
* @description: 自定义操作日志注解
*/
@Target(ElementType.METHOD) //方法
@Retention(RetentionPolicy.RUNTIME) //生命周期
@Documented
public @interface OperationLogAnnotation {
String operModul() default ""; // 操作模块
String operType() default ""; // 操作类型
String operDesc() default ""; // 操作说明
boolean saveContent() default false;
}
package com.baosight.hpjx.common;
import com.baosight.iplat4j.core.ei.EiBlock;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public enum CompanyTypeEnum {
GQ(1,"国企"),
MY(2,"民营");
private Integer code;
private String value;
CompanyTypeEnum(Integer code, String value) {
this.code = code;
this.value = value;
}
public static EiBlock generatorEiBlock() {
EiBlock block = new EiBlock("company_type_block_id");
List<Map<String, Object>> rows = new ArrayList<Map<String, Object>>() {{
add(new HashMap<String, Object>() {{
put(HPConstants.TEXT_FIELD, GQ.code + "-" + GQ.value);
put(HPConstants.VALUE_FIELD, GQ.code);
}});
add(new HashMap<String, Object>() {{
put(HPConstants.TEXT_FIELD, MY.code + "-" + MY.value);
put(HPConstants.VALUE_FIELD, MY.code);
}});
}};
block.setRows(rows);
return block;
}
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.common;
import com.baosight.iplat4j.core.ei.EiBlock;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author wwl
* @Date 2024/1/9 19:25
*/
public enum CustomerTypeEnum {
SUPPLIER(1,"供应商"),
CUSTOMER(2,"客户");
private Integer code;
private String value;
CustomerTypeEnum(Integer code, String value) {
this.code = code;
this.value = value;
}
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;
}
public static EiBlock generatorEiBlock() {
EiBlock block = new EiBlock("customer_type_block_id");
List<Map<String, Object>> rows = new ArrayList<Map<String, Object>>() {{
add(new HashMap<String, Object>() {{
put(HPConstants.TEXT_FIELD, SUPPLIER.code);
put(HPConstants.VALUE_FIELD, SUPPLIER.value);
}});
add(new HashMap<String, Object>() {{
put(HPConstants.TEXT_FIELD, CUSTOMER.code);
put(HPConstants.VALUE_FIELD, CUSTOMER.value);
}});
}};
block.setRows(rows);
return block;
}
}
package com.baosight.hpjx.common;
/**
* ErrorCodeEnum
*
* @author 张弘毅
* @date 2018-10-31 14:21
*/
public enum ErrorCodeEnum {
//数据库常见异常列表
DB_ERROR_CODE_F803("-803","数据库中已有相同主键的条目,错误编码:-803"),//不能插入行,因为这将违反唯一索引的约束
DB_ERROR_CODE_Z204("+204","命名的对象未在DB2中定义,错误编码:+204"),
DB_ERROR_CODE_F204("-204","没有定义的对象名,错误编码:-204"),
DB_ERROR_CODE_F302("-302","新增或修改中有数据不符合要求,错误编码:-302"),//输入的变量值对指定的列无效
DB_ERROR_CODE_F402("-402","算术函数不能用于字符或日期时间数据,错误编码:-402"),
DB_ERROR_CODE_F119("-119","HAVING语句中的列的列表与GROUP BY语句中的列列表不匹配,错误编码:-119"),
DB_ERROR_CODE_F117("-117","待插入的数值的个数于被插入的行中的列数不相等,错误编码:-117"),
DB_ERROR_CODE_F407("-407","主键不能有空或全为空,错误编码:-407"),
;
private String code;
private String description;
ErrorCodeEnum(String code, String description) {
this.code = code;
this.description = description;
}
public String getCode() {
return code;
}
public String getDescription() {
return description;
}
}
package com.baosight.hpjx.common;
/**
* @author xuao
* @date 2024年01月09日 14:53
*/
public class HPConstants {
/** 多字段拼接符号 XTC */
public static final String BLOCK_DETAIL = "detail";
//公司編碼
public static final String SQL_FIELD_COMPANYCODE = "companyCode";
//創建人
public static final String SQL_FIELD_CREATED_BY = "createdBy";
//創建人名称
public static final String SQL_FIELD_CREATED_NAME = "createdName";
//創建時間
public static final String SQL_FIELD_CREATED_TIME = "createdTime";
//修改人
public static final String SQL_FIELD_UPDATED_BY = "updatedBy";
//修改人名称
public static final String SQL_FIELD_UPDATED_NAME = "updatedName";
//修改時間
public static final String SQL_FIELD_UPDATED_TIME = "updatedTime";
//代碼名字分隔符
public static final String SPLICING_SYMBOL = "-";
/** 前后台交互下拉框字段 字段名 dzg */
public static final String TEXT_FIELD = "textField";
/** 前后台交互下拉框字段 字段名 dzg */
public static final String PARAM1_FIELD = "param1Field";
/** 前后台交互下拉框字段 字段名 dzg */
public static final String PARAM2_FIELD = "param2Field";
/** 前后台交互下拉框字段 字段名 dzg */
public static final String PARAM3_FIELD = "param3Field";
/** 前后台交互下拉框字段 字段名 dzg */
public static final String PARAM4_FIELD = "param4Field";
/** 前后台交互下拉框字段 字段名 dzg */
public static final String PARAM5_FIELD = "param5Field";
/** 前后台交互下拉框字段 字段名 dzg */
public static final String PARAM6_FIELD = "param6Field";
/** 前后台交互下拉框字段 字段名 dzg */
public static final String VALUE_FIELD = "valueField";
public static final String PARAM_FILENAME = "fileName";
/** domain字段 PARAM_FILENAME 导入文件暂存路径 LC*/
public static final String PARAM_CLASSNAME = "className";
}
package com.baosight.hpjx.common;
import com.baosight.iplat4j.core.ei.EiBlock;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author wwl
* @Date 2024/1/9 19:16
*/
public enum InitiateModeEnum {
STOP(0,"停用"),
USING(1,"启用");
private Integer code;
private String value;
InitiateModeEnum(Integer code, String value) {
this.code = code;
this.value = value;
}
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;
}
public static EiBlock generatorEiBlock(){
EiBlock block = new EiBlock("initiate_mode_block_id");
List<Map<String,Object>> rows = new ArrayList<Map<String,Object>>(){{
add(new HashMap<String,Object>(){{
put(HPConstants.TEXT_FIELD,STOP.code);
put(HPConstants.VALUE_FIELD,STOP.value);
}});
add(new HashMap<String,Object>(){{
put(HPConstants.TEXT_FIELD,USING.code);
put(HPConstants.VALUE_FIELD,USING.value);
}});
}};
block.setRows(rows);
return block;
}
}
package com.baosight.hpjx.common;
import com.baosight.iplat4j.core.ei.EiBlock;
import java.util.*;
/**
* @Author wwl
* @Date 2024/1/10 14:29
*/
public enum InventTypeEnum {
RAW(1,"原料"),
CONSUMABLE(2,"耗材"),
SEMI_FINISHED_PRODUCT(3,"零件"),
FINISHED_PRODUCT(4,"部件"),
WASTE(5,"废料"),
OTHER(6,"其他"),
MATERIAL(7,"材料");
private Integer code;
private String value;
InventTypeEnum(Integer code, String value) {
this.code = code;
this.value = value;
}
public static InventTypeEnum getEnumByCode(Integer code){
for (InventTypeEnum en : InventTypeEnum.values()){
if(code.compareTo(en.code)==0){
return en;
}
}
return null;
}
public static String getNameByCode(Integer code){
InventTypeEnum en = getEnumByCode(code);
if(Objects.nonNull(en)){
return en.getValue();
}
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;
}
public static Integer[] getProdTypes(){
return new Integer[]{SEMI_FINISHED_PRODUCT.code,FINISHED_PRODUCT.code};
}
public static EiBlock generatorEiBlock() {
EiBlock block = new EiBlock("customer_type_block_id");
List<Map<String, Object>> rows = new ArrayList<Map<String, Object>>() {{
add(new HashMap<String, Object>() {{
put(HPConstants.TEXT_FIELD, MATERIAL.code + HPConstants.SPLICING_SYMBOL + MATERIAL.value);
put(HPConstants.VALUE_FIELD, MATERIAL.code);
}});
add(new HashMap<String, Object>() {{
put(HPConstants.TEXT_FIELD, CONSUMABLE.code + HPConstants.SPLICING_SYMBOL + CONSUMABLE.value);
put(HPConstants.VALUE_FIELD, CONSUMABLE.code);
}});
add(new HashMap<String, Object>() {{
put(HPConstants.TEXT_FIELD, SEMI_FINISHED_PRODUCT.code + HPConstants.SPLICING_SYMBOL + SEMI_FINISHED_PRODUCT.value);
put(HPConstants.VALUE_FIELD, SEMI_FINISHED_PRODUCT.code);
}});
add(new HashMap<String, Object>() {{
put(HPConstants.TEXT_FIELD, FINISHED_PRODUCT.code + HPConstants.SPLICING_SYMBOL + FINISHED_PRODUCT.value);
put(HPConstants.VALUE_FIELD, FINISHED_PRODUCT.code);
}});
}};
block.setRows(rows);
return block;
}
}
package com.baosight.hpjx.common;
/**
* @author:songx
* @date:2024/2/5,11:33
*/
public enum ProdOrderStatusEnum {
NOT_ASSIGN(0, "未分派"),
PART_ASSIGN(1, "部分分派"),
ALL_ASSIGN(2, "全部分派");
private Integer code;
private String value;
ProdOrderStatusEnum(Integer code, String value) {
this.code = code;
this.value = value;
}
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.controller;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.MapUtils;
import com.baosight.hpjx.util.StringUtils;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.soa.XServiceManager;
import com.baosight.iplat4j.eu.dm.document.bos.s3.api.signed.SignedBosHelp;
import com.baosight.iplat4j.eu.dm.document.bos.s3.param.BosParamHelp;
import com.baosight.hpjx.util.FileUtils;
import com.google.common.base.Joiner;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import lombok.extern.slf4j.Slf4j;
/**
* @author:songx
* @date:2024/3/14,14:26
*/
@Slf4j
@Controller
@CrossOrigin
@RequestMapping({"/file/download"})
public class FileDownloadController {
/**
* 更具docId下载文件
*
* @param docId
* @param request
* @param response
* @throws IOException
*/
@RequestMapping({"/{docId}"})
public void downloadUrl(@PathVariable String docId, HttpServletRequest request, HttpServletResponse response)
throws IOException {
response.setContentType("text/plain; charset=UTF-8");
try {
EiInfo queryDocMapInfo = new EiInfo();
queryDocMapInfo.set("docId", docId);
queryDocMapInfo.set(EiConstant.serviceId, "S_EU_0102");
EiInfo returnInfo = XServiceManager.call(queryDocMapInfo);
Map docMap = returnInfo.getMap("docMap");
String s3UrlPrefix = MapUtils.getString(docMap, "url");
String fileName = MapUtils.getString(docMap, "resCname");
String returnUrlPrefix = BosParamHelp.disposeUrl(s3UrlPrefix);
Map<String, String[]> parameterMap = request.getParameterMap();
String returnUrl = this.getReturnUrlByParam(parameterMap, returnUrlPrefix);
if (StringUtils.isBlank(returnUrl)) {
String seconds = request.getHeader("seconds");
if (StringUtils.isBlank(seconds)) {
seconds = request.getParameter("seconds");
}
returnUrl = this.buildReturnUrl(seconds, fileName, returnUrlPrefix, s3UrlPrefix);
}
// 下载文件
if (StringUtils.isNotBlank(returnUrl)) {
FileUtils.downloadUrlFile(returnUrl, fileName, response);
} else {
throw new PlatException("文件地址异常");
}
} catch (Exception e) {
String msg = String.format("下载文件【%s】失败!原因:%s", docId, LogUtils.getMsg(e));
response.getWriter().write(msg);
}
}
private String getReturnUrlByParam(Map<String, String[]> parameterMap, String returnUrl)
throws UnsupportedEncodingException {
String returnUrl2 = "";
Map<String, String> paramMap = this.getParamMap(parameterMap);
paramMap.remove("code");
paramMap.remove("access_token");
paramMap.remove("seconds");
if (!paramMap.isEmpty() && paramMap.containsKey("X-Amz-Signature")) {
String queryString = this.buildQueryString(paramMap);
returnUrl2 = returnUrl + "?" + queryString;
}
return returnUrl2;
}
private String buildReturnUrl(String seconds, String fileName, String returnUrlPrefix, String s3UrlPrefix)
throws Exception {
URL s3Url = SignedBosHelp.getDownloadTempUrl(s3UrlPrefix, fileName, seconds);
String s3UrlParam = StringUtils.defaultIfEmpty(s3Url.getQuery(), "");
String returnUrl = returnUrlPrefix + "?" + s3UrlParam;
return com.baosight.iplat4j.eu.dm.util.FileUtils.returnDocUrlByEncodeFileName(returnUrl);
}
private Map<String, String> getParamMap(Map<String, String[]> parameterMap) {
Map paramMap = new HashMap();
Set<String> parameterSet = parameterMap.keySet();
Iterator parameterIterator = parameterSet.iterator();
while (parameterIterator.hasNext()) {
String next = (String) parameterIterator.next();
String[] valueArray = (String[]) parameterMap.get(next);
if (valueArray != null && valueArray.length != 0) {
String value = Joiner.on(",").join(valueArray);
paramMap.put(next, value);
}
}
return paramMap;
}
private String buildQueryString(Map<String, String> parameterMap) throws UnsupportedEncodingException {
StringBuilder strBuilder = new StringBuilder();
String rcd = MapUtils.getString(parameterMap, "response-content-disposition");
parameterMap.remove("response-content-disposition");
String next;
for (Iterator iterator = parameterMap.keySet().iterator(); iterator.hasNext();
strBuilder.append(next).append("=").append((String) parameterMap.get(next))) {
next = (String) iterator.next();
if (strBuilder.length() > 0) {
strBuilder.append("&");
}
}
if (StringUtils.isNotBlank(rcd)) {
strBuilder.append("&").append("response-content-disposition").append("=").append(
URLEncoder.encode(rcd, "UTF-8"));
}
return strBuilder.toString();
}
}
package com.baosight.hpjx.core.api;
import com.alibaba.fastjson.JSONObject;
import com.baosight.hpjx.util.Base64Utils;
import com.baosight.hpjx.util.FileUtils;
import com.baosight.hpjx.util.HttpUtils;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
/**
* @author:songx
* @date:2024/1/29,9:16
*/
@Slf4j
public class BaiDuApi {
// // 鉴权接口
// private static final String TOKEN_URL = "https://aip.baidubce.com/oauth/2.0/token";
// // 标准版接口地址
// private static final String BASIC_URL = "https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic";
// // 办公文档版接口地址
// private static final String OFFICE_URL = "https://aip.baidubce.com/rest/2.0/ocr/v1/doc_analysis_office";
// // Api Key
// private static final String API_KEY = "dkXgTCScKjfMmL7oCzAIFdgZ";
// // Secret Key
// private static final String SECRET_KEY = "xP5V9k23KBNHOyzc0rYkm00GdQMMxvEh";
//
// /**
// * 获取TOKEN
// *
// * @return
// */
// public static String getToken() {
// return SingletonHolder.TOKEN;
// }
//
// /**
// * 刷新TOKEN
// *
// * @return
// */
// public static void refreshToken() {
// SingletonHolder.refresh();
// }
//
// public static void main(String[] args) throws IOException {
//// String filePath = "e:/10001.jpg";
// String filePath = "e:/新年贺词.pdf";
// docAnalysisOffice(filePath);
// }
//
// /**
// * 解析办公文档
// *
// * @param filePath 本地文件地址
// */
// public static void docAnalysisOffice(String filePath) throws IOException {
// byte[] fileBytes = FileUtils.readByBytes(filePath);
// String fileBase64 = Base64Utils.encode(fileBytes);
// String fileEncoder = URLEncoder.encode(fileBase64, "UTF-8");
// String param = "pdf_file_num=2&image=" + fileEncoder;
// Map<String, String> header = new HashMap<>();
// header.put("Content-Type", "application/x-www-form-urlencoded");
// String url = OFFICE_URL + "?access_token=" + getToken();
// String result = HttpUtils.post(url, header, param, HttpUtils.FORM_MEDIA_TYPE);
// log.info("result->{}", result);
// }
/**
* 静态内部类用于初始化
*
* @author:songx
* @date:2022/5/9,15:48
*/
private static class SingletonHolder {
// /**
// * 默认DAO
// */
// private static String TOKEN = "24.717d5b52074bdf31d0377a4afa6c97d6.2592000.1709101017.282335-48528257";//getToken();
//
// /**
// * 获取TOKEN
// *
// * @return
// * @throws IOException
// */
// private static String getToken() {
// try {
// String url = String.format("%s?client_id=%s&client_secret=%s&grant_type=client_credentials",
// TOKEN_URL, API_KEY, SECRET_KEY);
// String result = HttpUtils.post(url);
// JSONObject resultJson = JSONObject.parseObject(result);
// return resultJson.getString("access_token");
// } catch (Exception e) {
// log.error("获取百度API的TOKEN失败:{}", e.getMessage(), e);
// }
// return null;
// }
//
// /**
// * 刷新TOKEN
// *
// * @return
// */
// public static void refresh() {
// TOKEN = getToken();
// }
}
}
package com.baosight.hpjx.core.configuration;
import com.baosight.iplat4j.core.ioc.spring.PlatApplicationContext;
import com.baosight.iplat4j.eu.dm.PlatFileUploadManagerByAmazonS3;
import com.baosight.iplat4j.eu.dm.util.PlatFileUploader;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import lombok.extern.slf4j.Slf4j;
/**
* 初始化注入bean
*
* @author:songx
* @date:2024/3/13,15:03
*/
@Slf4j
@Configuration
@ConditionalOnProperty(
name = {"iplat4j.admin.objectStorage.s3.switch"},
havingValue = "on"
)
public class ConfigurationBean {
@Bean(name = "platFileUploader")
public PlatFileUploader newPlatFileUploader() {
return new PlatFileUploader();
}
@Bean(name = "fileUpLoadManager")
public PlatFileUploadManagerByAmazonS3 newPlatFileUploadManagerByAmazonS3() {
return new PlatFileUploadManagerByAmazonS3();
}
}
package com.baosight.hpjx.core.constant;
import com.baosight.hpjx.util.StringUtils;
/**
* @author:songx
* @date:2024/3/1,17:36
*/
public class CodesetConstant {
/**
* 组织机构
*
* @author:songx
* @date:2024/3/1,17:36
*/
public static class XsOg {
// 组织机构类型
public static final String ORG_TYPE = "xs.og.orgType";
}
}
package com.baosight.hpjx.core.constant;
/**
* @author:songx
* @date:2022/11/1,17:08
*/
public class CommonConstant {
/**
* 环境变量
*
* @author:songx
* @date:2024/1/20,15:04
*/
public static class projectEnv {
// 开发环境
public static final String DEV = "dev";
// 正式环境
public static final String RUN = "run";
}
/**
* 是否
*
* @author:songx
* @date:2022/11/1,17:09
*/
public static class YesNo {
// 是
public static final Integer YES_1 = 1;
// 否
public static final Integer NO_0 = 0;
// 是
public static final String YES = "Y";
// 否
public static final String NO = "N";
}
/**
* 日期类型
*
* @author:songx
* @date:2024/1/20,15:04
*/
public static class DateType {
// 月
public static final String MONTH = "MONTH";
// 日
public static final String DAY = "DAY";
}
/**
* 常用字段常量
*
* @author:songx
* @date:2024/2/22,15:33
*/
public static class Field {
// DETAIL
public static final String DETAIL = "detail";
// ID
public static final String ID = "id";
// 生产订单号
public static final String PROD_ORDER_NO = "prodOrderNo";
// 生产订单号2
public static final String PRODUCTTION_ORDER_NO = "productionOrderNo";
// ROOT
public static final String ROOT = "root";
}
}
package com.baosight.hpjx.core.constant;
/**
* 平台消息统一存放key
*
* @author:songx
* @date:2024/3/12,10:49
*/
public class EPCodeConstant {
// 许可证不正确
public static final String EP_0000 = "ep.0000";
// 页面不存在或禁止访问
public static final String EP_0010 = "ep.0010";
// 页面不存在或禁止访问
public static final String EP_0012 = "ep.0012";
// 您所访问的页面没有访问权限
public static final String ES001 = "ES001";
// 空白页
public static final String ES999 = "ES999";
// 500页面
public static final String ES500 = "ES500";
}
/*
* 武汉理工数字传播工程有限公司源代码,版权归武汉理工数字传播工程有限公司所有.
* 项目名称 : pcloud-common
* 创建日期 : 2017年3月3日
* 修改历史 :
* 1. [2017年3月3日]创建文件 by xnxqs
*/
package com.baosight.hpjx.core.constant;
/**
* 与操作系统 有关的一些常量.
*
* @author:songx
* @date:2019/12/12,16:32
*/
public class OSConstant {
/**
* 文件夹分隔符,不同OS下分隔符不同
*/
public final static String SEPARATOR = System.getProperty("file.separator");
/**
* 程序运行目录
*/
public final static String USER_DIR = System.getProperty("user.dir");
/**
* 逗号
*/
public final static String COMMA = ",";
/**
* 程序运行目录
*/
public final static String DOWN_DIR = USER_DIR + SEPARATOR + "download";
}
package com.baosight.hpjx.core.dao;
import com.baosight.iplat4j.core.data.ibatis.dao.Dao;
import com.baosight.iplat4j.core.ioc.spring.PlatApplicationContext;
/**
* 数据库操作辅助类
*
* @author:songx
* @date:2022/5/9,15:41
*/
public class DaoBase {
private DaoBase() {
}
/**
* 获取DAO
*
* @return
*/
public static Dao getInstance() {
return SingletonHolder.dao;
}
/**
* 获取DAO
*
* @return
*/
public static Dao getPlatInstance() {
return SingletonHolder.platDao;
}
/**
* 静态内部类用于初始化
*
* @author:songx
* @date:2022/5/9,15:48
*/
private static class SingletonHolder {
/**
* 默认DAO
*/
private final static Dao dao = (Dao) PlatApplicationContext.getBean("dao");
/**
* platDao
*/
private final static Dao platDao = (Dao) PlatApplicationContext.getBean("platDao");
}
}
package com.baosight.hpjx.core.dao;
import com.baosight.hpjx.core.security.UserSessionUtils;
import com.baosight.hpjx.hp.xs.tools.HPXSTools;
import com.baosight.hpjx.util.AssertUtils;
import com.baosight.hpjx.util.DateUtils;
import com.baosight.iplat4j.core.data.DaoEPBase;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.web.threadlocal.UserSession;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
/**
* @author:songx
* @date:2023/10/18,16:35
*/
@Slf4j
public class DaoUtils {
/**
* count 查询
*
* @param sqlName
* @param paramMap
* @return
*/
public static int count(String sqlName, Map paramMap) {
AssertUtils.isEmpty(sqlName, "sql name不能为空!");
List<Integer> countMaps = DaoBase.getInstance().query(sqlName, paramMap);
return CollectionUtils.isEmpty(countMaps) ? 0 : countMaps.get(0).intValue();
}
/**
* insert method.
*
* @param sql
* @param obj
*/
public static void insert(String sql, Object obj) throws PlatException {
if (obj instanceof DaoEPBase) {
setCreator((DaoEPBase) obj);
} else if (obj instanceof Map) {
setCreator((Map) obj);
} else if (obj instanceof List) {
for (Object o : ((List) obj)) {
insert(sql, o);
}
return;
}
DaoBase.getInstance().insert(sql, obj);
}
/**
* update method.
*
* @param sql
* @param obj
*/
public static int update(String sql, Object obj) {
if (obj instanceof DaoEPBase) {
setRevisor((DaoEPBase) obj, true);
} else if (obj instanceof Map) {
setRevisor((Map) obj, true);
}
return DaoBase.getInstance().update(sql, obj);
}
/**
* 创建人工号 创建人姓名 创建人岗号 创建时刻
*
* @param bean
*/
private static void setCreator(DaoEPBase bean) {
// 创建人ID
String userId;
try {
userId = UserSession.getLoginName();
userId = userId == null || userId.length() > 32 ? "System" : userId;
} catch (Exception e) {
userId = "System";
}
try {
BeanUtils.setProperty(bean, "createdBy", userId);
BeanUtils.setProperty(bean, "updatedBy", "");
} catch (Exception e) {
log.warn("写入创建人ID失败", e);
}
// 创建人姓名
try {
String userName;
try {
userName = UserSession.getLoginCName();
} catch (Exception e) {
userName = "System";
}
BeanUtils.setProperty(bean, "createdName", userName);
BeanUtils.setProperty(bean, "updatedName", "");
} catch (Exception e) {
log.warn("写入创建人姓名失败", e);
}
// 创建人企业编码
try {
String companyCode;
try {
companyCode = UserSessionUtils.getCompanyCode();
} catch (Exception e) {
companyCode = "";
}
BeanUtils.setProperty(bean, "companyCode", companyCode);
} catch (Exception e) {
log.warn("写入创建人企业编码失败", e);
}
// 创建人部门编码
try {
BeanUtils.setProperty(bean, "depCode", HPXSTools.getOrgId());
} catch (Exception e) {
log.warn("写入创建人企业编码失败", e);
}
// 创建时刻
try {
BeanUtils.setProperty(bean, "createdTime", DateUtils.shortDateTime());
BeanUtils.setProperty(bean, "updatedTime", "");
} catch (Exception e) {
log.error("写入创建时刻失败:{}", e.getMessage(), e);
}
}
/**
* 创建人工号 创建人姓名 创建时刻.
*
* @param map
*/
public static void setCreator(Map map) {
// 创建人工号
String userId = MapUtils.getString(map, "createdBy");
try {
if (StringUtils.isEmpty(userId)) {
userId = UserSession.getLoginName();
userId = userId == null || userId.length() > 32 ? "System" : userId;
}
} catch (Exception e) {
userId = "System";
}
map.put("createdBy", userId);
map.put("updatedBy", "");
// 创建人姓名
String userName = MapUtils.getString(map, "createdName");
try {
if (StringUtils.isEmpty(userName)) {
userName = UserSession.getLoginCName();
}
} catch (Exception e) {
userName = "System";
}
map.put("createdName", userName);
map.put("updatedName", "");
// 创建人企业编码
try {
String companyCode;
try {
companyCode = UserSessionUtils.getCompanyCode();
} catch (Exception e) {
companyCode = "";
}
map.put("companyCode", companyCode);
} catch (Exception e) {
log.warn("写入创建人企业编码失败", e);
}
// 创建人部门编码
try {
map.put("depCode", HPXSTools.getOrgId());
} catch (Exception e) {
log.warn("写入创建人企业编码失败", e);
}
// 创建时刻
try {
map.put("createdTime", DateUtils.shortDateTime());
map.put("updatedTime", "");
} catch (PlatException e) {
log.warn("写入创建时刻失败", e);
}
}
/**
* 修改人工号 修改人姓名 修改人岗号 修改时刻 记录修改代理人工号 记录修改代理人姓名.
*
* @param bean
* @param addJobId
*/
private static void setRevisor(DaoEPBase bean, Boolean addJobId) {
// 修改人ID
String userId;
try {
userId = UserSession.getLoginName();
userId = userId == null || userId.length() > 32 ? "System" : userId;
} catch (Exception e) {
userId = "System";
}
try {
BeanUtils.setProperty(bean, "updatedBy", userId);
} catch (Exception e) {
log.warn("写入修改人ID失败", e);
}
// 修改人名称
try {
String userName = UserSession.getLoginCName();
BeanUtils.setProperty(bean, "updatedName", userName);
} catch (Exception e) {
log.warn("写入修改人名称失败", e);
}
// 修改时刻
try {
BeanUtils.setProperty(bean, "updatedTime", DateUtils.shortDateTime());
} catch (Exception e) {
log.warn("写入修改时刻失败", e);
}
}
/**
* 修改人工号 修改人姓名 修改人岗号 修改时刻 记录修改代理人工号 记录修改代理人姓名.
*
* @param map
* @param addJobId
*/
private static void setRevisor(Map map, Boolean addJobId) {
String userId;
try {
userId = MapUtils.getString(map, "updatedBy");
if (StringUtils.isBlank(userId)) {
userId = UserSession.getLoginName();
userId = userId == null || userId.length() > 32 ? "System" : userId;
}
} catch (Exception e) {
userId = "System";
}
map.put("updatedBy", userId);
// 修改人名称
String userName = MapUtils.getString(map, "updatedName");
try {
if (StringUtils.isBlank(userName)) {
userName = UserSession.getLoginCName();
}
} catch (Exception e) {
userName = "System";
}
map.put("updatedName", userName);
// 修改时间
map.put("updatedTime", DateUtils.shortDateTime());
}
}
package com.baosight.hpjx.core.enums;
/**
* @author:songx
* @date:2024/3/1,17:29
*/
public enum OrgTypeEnum {
FACTORY("factory", "厂区"),
DEPT("dept", "部门"),
PROD_GROUP("prodGroup", "生产组"),
CUT_GROUP("cutGroup", "下料组"),
;
private String code;
private String value;
OrgTypeEnum(String code, String value) {
this.code = code;
this.value = value;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
package com.baosight.hpjx.core.enums;
/**
* @author:songx
* @date:2024/3/1,17:29
*/
public enum UserStatusEnum {
ONLINE(1, "在职"),
OFFLINE(2, "离职"),
;
private Integer code;
private String value;
UserStatusEnum(Integer code, String value) {
this.code = code;
this.value = value;
}
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.exception;
import com.baosight.hpjx.core.constant.EPCodeConstant;
import com.baosight.hpjx.core.tools.ServletTools;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* @author:songx
* @date:2024/3/11,14:58
*/
@RestControllerAdvice
public class GlobalExceptionHandler {
@Autowired
private HttpServletRequest request;
@Autowired
private HttpServletResponse response;
/**
* RuntimeException
*
* @param e
* @throws IOException
* @throws ServletException
*/
@ExceptionHandler(Exception.class)
public void exceptionHandler(Exception e) throws IOException, ServletException {
// 权限异常
if (e instanceof AccessDeniedException) {
ServletTools.dispatcherError(EPCodeConstant.ES001, request.getServletPath(), request, response);
} else if (e instanceof ClassNotFoundException) {
// class不存在
ServletTools.dispatcherError(EPCodeConstant.EP_0010, request.getServletPath(), request, response);
} else {
ServletTools.dispatcherError(EPCodeConstant.ES500, "您所访问的服务出错了", request, response);
}
}
}
package com.baosight.hpjx.core.filter;
import com.baosight.hpjx.core.constant.EPCodeConstant;
import com.baosight.hpjx.core.tools.ServletTools;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpHeaders;
import org.springframework.security.web.firewall.RequestRejectedException;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.GenericFilterBean;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import lombok.extern.slf4j.Slf4j;
/**
* 滤波器处理
*
* @author:songx
* @date:2024/3/12,10:32
*/
@Slf4j
@Component
@Order(Ordered.HIGHEST_PRECEDENCE)
public class MyGenericFilter extends GenericFilterBean {
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) servletRequest;
HttpServletResponse response = (HttpServletResponse) servletResponse;
try {
chain.doFilter(servletRequest, servletResponse);
} catch (RequestRejectedException e) {
log.warn("request_rejected: remote={}, user_agent={}, request_url={}", request.getRemoteHost(),
request.getHeader(HttpHeaders.USER_AGENT), request.getRequestURL(), e);
ServletTools.dispatcherError(EPCodeConstant.EP_0010, request.getServletPath(), request, response);
}
}
}
package com.baosight.hpjx.core.interceptor;
import com.baosight.hpjx.core.constant.EPCodeConstant;
import com.baosight.hpjx.core.tools.ServletTools;
import com.baosight.hpjx.util.ObjectUtils;
import com.baosight.hpjx.util.StringUtils;
import com.baosight.iplat4j.core.ProjectInfo;
import com.baosight.iplat4j.core.ioc.spring.PlatApplicationContext;
import com.baosight.xservices.xs.util.LoginUserDetails;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import lombok.extern.slf4j.Slf4j;
/**
* 自定义拦截器
*
* @author:songx
* @date:2022/10/9,8:58
*/
@Slf4j
public class MyHandlerInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception {
try {
// 设置环境变量
request.setAttribute("projectEnv", ProjectInfo.getProjectEnv());
// 校验接口权限
boolean isInterfaceAuth = this.checkUserInterfaceAuth(request, response);
if (!isInterfaceAuth) {
return false;
}
} catch (IOException e) {
log.error("重定向失败:{}", e.getMessage(), e);
}
return true;
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object o,
ModelAndView modelAndView) throws Exception {
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object o, Exception e) {
}
/**
* 校验用户
*
* @param request
* @param response
*/
private boolean checkUserInterfaceAuth(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
HttpSession session = request.getSession();
String loginName = ObjectUtils.toString(session.getAttribute("loginname"));
String servletPath = request.getServletPath();
// // 从路径中截取页面号和方法名,例:/service/EDFA10/query
String[] servletPaths = servletPath.split("/");
// 异常请求不记录
if (servletPaths.length > 2 && "$src_url$".equals(servletPaths[2])) {
return true;
}
// length=3:接口
return this.checkInterfaceAuth(loginName, servletPaths, request, response);
}
/**
* 用户接口权限校验
* servletPaths.length=3:接口
*
* @param loginName
* @param servletPaths
* @param request
* @param response
*/
private boolean checkInterfaceAuth(String loginName, String[] servletPaths, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
if (servletPaths.length != 4) {
return true;
}
// 从配置中读取需要验证的模块
String interfaceAuth = PlatApplicationContext.getProperty("iplat4j.interface.auth.module");
if (StringUtils.isBlank(interfaceAuth)) {
return true;
}
// 检查模块是否需要管理员权限
String moduleName = ServletTools.getModule(request);
if (!StringUtils.startsWithAny(moduleName, interfaceAuth.split(";"))) {
return true;
}
// 是超级管理员
if (LoginUserDetails.isUserAdmin(loginName)) {
return true;
}
ServletTools.dispatcherError(EPCodeConstant.ES001, request.getServletPath(), request, response);
return false;
}
}
package com.baosight.hpjx.core.interceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* @author:songx
* @date:2023/11/23,11:13
*/
@Configuration
public class MyWebMvcConfigurer implements WebMvcConfigurer {
/**
* 配置拦截规则与注入拦截器
*
* @param registry
*/
@Override
public void addInterceptors(InterceptorRegistry registry) {
// addPathPattern 添加拦截规则 /** 拦截所有包括静态资源
// excludePathPattern 排除拦截规则 所以我们需要放开静态资源的拦截
registry.addInterceptor(new MyHandlerInterceptor())
.addPathPatterns("/service/**")
.addPathPatterns("/web/**")
.addPathPatterns("/**")
// .excludePathPatterns("/")
.excludePathPatterns("/login")
.excludePathPatterns("/css/**", "/fonts/**", "/images/**", "/js/**");
}
}
package com.baosight.hpjx.core.security;
import com.baosight.hpjx.hp.xs.domain.User;
import com.baosight.hpjx.hp.xs.tools.HPXSTools;
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.threadlocal.UserSession;
import com.baosight.xservices.xs.util.LoginUserDetails;
import org.apache.commons.collections.MapUtils;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
* @author:songx
* @date:2024/1/15,14:48
*/
public class UserSessionUtils extends UserSession {
private static ConcurrentMap companyMap = new ConcurrentHashMap();
private static ConcurrentMap depMap = new ConcurrentHashMap();
private static ConcurrentMap userAdminMap = new ConcurrentHashMap();
/**
* 获取用户信息
*
* @return
*/
public static User getUser() {
EiInfo eiInfo = new EiInfo();
eiInfo.set("userId", UserSession.getUserId());
eiInfo.set(EiConstant.serviceName, "HPXSUser");
eiInfo.set(EiConstant.methodName, "getUser");
EiInfo outInfo = XLocalManager.call(eiInfo);
// -1表示报错
if (outInfo.getStatus() == -1) {
throw new PlatException("无法调用用户信息");
}
// 状态为0表示不存在此用户
if (outInfo.getStatus() == 0) {
return null;
}
// 其它状态,异常
if (outInfo.getStatus() != 1) {
throw new PlatException(outInfo.getMsg());
}
// 状态为1表示用户存在
return (User) outInfo.get(EiConstant.resultBlock);
}
/**
* 获取登录用户的公司编码
*
* @return
*/
public static String getCompanyCode() {
String loginName = getLoginName();
if (loginName == null) {
return null;
}
String companyCode = MapUtils.getString(companyMap, loginName);
if (companyCode == null) {
User user = getUser();
companyCode = user == null || user.getCompanyCode() == null ? "" : user.getCompanyCode();
companyMap.put(loginName, companyCode);
}
return companyCode;
}
/**
* 获取登录用户的部门编码
*
* @return
*/
public static String getDepCode() {
String loginName = getLoginName();
if (loginName == null) {
return null;
}
String depCode = MapUtils.getString(depMap, loginName);
if (depCode == null) {
depCode = HPXSTools.getOrgId();
depCode = depCode == null ? "" : depCode.trim();
depMap.put(loginName, depCode);
}
return depCode;
}
/**
* 获取登录用户是否超级管理员
*
* @return
*/
public static boolean isUserAdmin() {
String loginName = getLoginName();
if (loginName == null) {
return false;
}
Boolean isUserAdmin = MapUtils.getBoolean(userAdminMap, loginName);
if (isUserAdmin == null) {
isUserAdmin = LoginUserDetails.isUserAdmin(loginName);
userAdminMap.put(loginName, isUserAdmin);
}
return isUserAdmin;
}
}
package com.baosight.hpjx.core.tools;
import com.baosight.hpjx.util.StringUtils;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.soa.XServiceManager;
import java.util.List;
/**
* @author:songx
* @date:2023/4/13,14:38
*/
public class CodeValueTools {
/**
* getCodeValueList.
*
* @param codesetCode
* @return
*/
public static List getCodeValues(String codesetCode) {
return getCodeValues(codesetCode, null);
}
/**
* getCodeValueList.
*
* @param codesetCode
* @param condition
* @return
*/
public static List getCodeValues(String codesetCode, String condition) {
EiInfo callInfo = new EiInfo();
callInfo.set(EiConstant.serviceId, "S_ED_02");
callInfo.set("codeset", codesetCode);
if (StringUtils.isNotBlank(condition)) {
callInfo.set("condition", condition);
}
return (List) XServiceManager.call(callInfo).get("list");
}
}
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.core.exception.PlatException;
import org.apache.commons.collections.CollectionUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* ED工具类
*
* @author:songx
* @date:2022/8/10,13:55
*/
public class EDTools {
/**
* 页面工具类
*
* @author:songx
* @date:2024/2/6,16:26
*/
public static class EdFa00 {
/**
* 查询页面信息
*
* @param ename
* @return
*/
public static TEDFA00 query(String ename) {
AssertUtils.isNull(ename, "页面英文名称不能为空!");
Map<String, String> paramMap = new HashMap();
paramMap.put("form_ename", ename);
List<TEDFA00> results = DaoBase.getInstance().query("tedfa00.query", paramMap);
return CollectionUtils.isEmpty(results) ? null : results.get(0);
}
}
/**
* 小代码工具类
*
* @author:songx
* @date:2024/2/6,16:25
*/
public static class EdCm01 {
/**
* 查询小代码明细
*
* @param codeSetCode
* @return
*/
public static List<Map<String, Object>> list(String codeSetCode) {
AssertUtils.isNull(codeSetCode, "代码分类编码不能为空!");
Map<String, String> paramMap = new HashMap();
paramMap.put("codesetCode", codeSetCode);
List<Map<String, Object>> results = DaoBase.getInstance().query("EDCM01.queryDetail", paramMap);
if (CollectionUtils.isEmpty(results)) {
throw new PlatException("分类编码[" + codeSetCode + "]未配置代码明细!");
}
return results;
}
}
}
package com.baosight.hpjx.core.tools;
import com.baosight.hpjx.util.StringUtils;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* @author:songx
* @date:2024/3/12,10:38
*/
public class ServletTools {
/**
* 获取模块名称
*
* @return
*/
public static String getModule(HttpServletRequest request) {
String servletPath = request.getServletPath();
if (StringUtils.isBlank(servletPath)) {
return "";
}
String[] servletPaths = servletPath.split("/");
if (servletPaths == null || servletPaths.length < 3) {
return servletPath;
}
return servletPaths[2];
}
/**
* 重定向到错误信息展示页面
*
* @param msgKey
* @param message
*/
public static void dispatcherError(String msgKey, String message, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
request.setAttribute("iplat_msgKey", msgKey);
request.setAttribute("iplat_msg", message);
request.getRequestDispatcher("/EP/EP01.jsp").forward(request, response);
}
}
package com.baosight.hpjx.demo;
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.core.service.soa.XLocalManager;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
public class ServiceEEDM01 extends ServiceEPBase {
@Override
public EiInfo initLoad(EiInfo inInfo) {
return inInfo;
}
public EiInfo sendMsg(EiInfo inInfo) {
List list= new ArrayList<>();
Random r = new Random();
int i1 = r.nextInt(10);
for (int i=0;i<i1;i++){
LocalTime now = LocalTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");
String VALUE = now.format(formatter)+"--- 报警信息,当前报警是第"+i+"条";
list.add(VALUE);
}
EiInfo info = new EiInfo();
info.set(EiConstant.serviceName, "EMNT01");
info.set(EiConstant.methodName, "broadcastByUserForm");
info.set("formEname", "realAlarm");
info.set("alarmdatas", list);
info.set("alarmcount",i1);
info.set("user","admin");
EiInfo resultInfo = XLocalManager.call(info);
return inInfo;
}
public EiInfo sendServiceMsg(EiInfo inInfo) {
List list= new ArrayList<>();
Random r = new Random();
int i1 = r.nextInt(10);
for (int i=0;i<i1;i++){
LocalTime now = LocalTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");
String VALUE = now.format(formatter)+"--- 报警信息,当前报警是第"+i+"条";
Map map =new HashMap<>();
map.put("alarmdatas",VALUE);
list.add(map);
}
EiBlock block = inInfo.addBlock("result");
block.setRows(list);
block.set("count",i1);
return inInfo;
}
}
/**
* Generate time : 2024-01-08 18:33:20
* Version : 1.0
*/
package com.baosight.hpjx.demo.domain;
import com.baosight.iplat4j.core.ei.EiColumn;
import com.baosight.iplat4j.core.data.DaoEPBase;
import java.util.HashMap;
import java.util.Map;
import com.baosight.iplat4j.core.util.StringUtils;
/**
* Tveci002
*
*/
public class Tveci002 extends DaoEPBase {
private String resId = " "; /* 资源ID*/
private String resClass = " "; /* 资源类型*/
private String htmlCode = " "; /* html代码*/
private String cssCode = " "; /* 样式代码*/
private String javascriptCode = " "; /* js代码*/
private String recCreator = " "; /* 创建人员*/
private String recCreateTime = " "; /* 创建时间*/
private String recRevisor = " "; /* 更新人员*/
private String recReviseTime = " "; /* 更新时间*/
private String dependencies = " "; /* js依赖*/
/**
* initialize the metadata
*/
public void initMetaData() {
EiColumn eiColumn;
eiColumn = new EiColumn("resId");
eiColumn.setPrimaryKey(true);
eiColumn.setDescName("资源ID");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("resClass");
eiColumn.setPrimaryKey(true);
eiColumn.setDescName("资源类型");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("htmlCode");
eiColumn.setDescName("html代码");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("cssCode");
eiColumn.setDescName("样式代码");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("javascriptCode");
eiColumn.setDescName("js代码");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("recCreator");
eiColumn.setDescName("创建人员");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("recCreateTime");
eiColumn.setDescName("创建时间");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("recRevisor");
eiColumn.setDescName("更新人员");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("recReviseTime");
eiColumn.setDescName("更新时间");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("dependencies");
eiColumn.setDescName("js依赖");
eiMetadata.addMeta(eiColumn);
}
/**
* the constructor
*/
public Tveci002() {
initMetaData();
}
/**
* get the resId - 资源ID
* @return the resId
*/
public String getResId() {
return this.resId;
}
/**
* set the resId - 资源ID
*/
public void setResId(String resId) {
this.resId = resId;
}
/**
* get the resClass - 资源类型
* @return the resClass
*/
public String getResClass() {
return this.resClass;
}
/**
* set the resClass - 资源类型
*/
public void setResClass(String resClass) {
this.resClass = resClass;
}
/**
* get the htmlCode - html代码
* @return the htmlCode
*/
public String getHtmlCode() {
return this.htmlCode;
}
/**
* set the htmlCode - html代码
*/
public void setHtmlCode(String htmlCode) {
this.htmlCode = htmlCode;
}
/**
* get the cssCode - 样式代码
* @return the cssCode
*/
public String getCssCode() {
return this.cssCode;
}
/**
* set the cssCode - 样式代码
*/
public void setCssCode(String cssCode) {
this.cssCode = cssCode;
}
/**
* get the javascriptCode - js代码
* @return the javascriptCode
*/
public String getJavascriptCode() {
return this.javascriptCode;
}
/**
* set the javascriptCode - js代码
*/
public void setJavascriptCode(String javascriptCode) {
this.javascriptCode = javascriptCode;
}
/**
* get the recCreator - 创建人员
* @return the recCreator
*/
public String getRecCreator() {
return this.recCreator;
}
/**
* set the recCreator - 创建人员
*/
public void setRecCreator(String recCreator) {
this.recCreator = recCreator;
}
/**
* get the recCreateTime - 创建时间
* @return the recCreateTime
*/
public String getRecCreateTime() {
return this.recCreateTime;
}
/**
* set the recCreateTime - 创建时间
*/
public void setRecCreateTime(String recCreateTime) {
this.recCreateTime = recCreateTime;
}
/**
* get the recRevisor - 更新人员
* @return the recRevisor
*/
public String getRecRevisor() {
return this.recRevisor;
}
/**
* set the recRevisor - 更新人员
*/
public void setRecRevisor(String recRevisor) {
this.recRevisor = recRevisor;
}
/**
* get the recReviseTime - 更新时间
* @return the recReviseTime
*/
public String getRecReviseTime() {
return this.recReviseTime;
}
/**
* set the recReviseTime - 更新时间
*/
public void setRecReviseTime(String recReviseTime) {
this.recReviseTime = recReviseTime;
}
/**
* get the dependencies - js依赖
* @return the dependencies
*/
public String getDependencies() {
return this.dependencies;
}
/**
* set the dependencies - js依赖
*/
public void setDependencies(String dependencies) {
this.dependencies = dependencies;
}
/**
* get the value from Map
*/
public void fromMap(Map map) {
setResId(StringUtils.defaultIfEmpty(StringUtils.toString(map.get("resId")), resId));
setResClass(StringUtils.defaultIfEmpty(StringUtils.toString(map.get("resClass")), resClass));
setHtmlCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get("htmlCode")), htmlCode));
setCssCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get("cssCode")), cssCode));
setJavascriptCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get("javascriptCode")), javascriptCode));
setRecCreator(StringUtils.defaultIfEmpty(StringUtils.toString(map.get("recCreator")), recCreator));
setRecCreateTime(StringUtils.defaultIfEmpty(StringUtils.toString(map.get("recCreateTime")), recCreateTime));
setRecRevisor(StringUtils.defaultIfEmpty(StringUtils.toString(map.get("recRevisor")), recRevisor));
setRecReviseTime(StringUtils.defaultIfEmpty(StringUtils.toString(map.get("recReviseTime")), recReviseTime));
setDependencies(StringUtils.defaultIfEmpty(StringUtils.toString(map.get("dependencies")), dependencies));
}
/**
* set the value to Map
*/
public Map toMap() {
Map map = new HashMap();
map.put("resId",StringUtils.toString(resId, eiMetadata.getMeta("resId")));
map.put("resClass",StringUtils.toString(resClass, eiMetadata.getMeta("resClass")));
map.put("htmlCode",StringUtils.toString(htmlCode, eiMetadata.getMeta("htmlCode")));
map.put("cssCode",StringUtils.toString(cssCode, eiMetadata.getMeta("cssCode")));
map.put("javascriptCode",StringUtils.toString(javascriptCode, eiMetadata.getMeta("javascriptCode")));
map.put("recCreator",StringUtils.toString(recCreator, eiMetadata.getMeta("recCreator")));
map.put("recCreateTime",StringUtils.toString(recCreateTime, eiMetadata.getMeta("recCreateTime")));
map.put("recRevisor",StringUtils.toString(recRevisor, eiMetadata.getMeta("recRevisor")));
map.put("recReviseTime",StringUtils.toString(recReviseTime, eiMetadata.getMeta("recReviseTime")));
map.put("dependencies",StringUtils.toString(dependencies, eiMetadata.getMeta("dependencies")));
return map;
}
}
\ No newline at end of file
package com.baosight.hpjx.demo.service;
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.ServiceBase;
import com.baosight.hpjx.demo.domain.Tveci002;
import java.util.Map;
/**
* @author xuao
* @date 2024年01月08日 18:29
*/
public class ServiceEEDM02 extends ServiceBase {
public static final String INQU_STATUS_BLOCK = "inqu_status";
public static final String RESULT_BLOCK = "result";
/**
* 画面初始化.
*/
public EiInfo initLoad(EiInfo inInfo) {
Tveci002 tveci002 = new Tveci002();
EiInfo outInfo = super.initLoad(inInfo, tveci002);
outInfo.addBlock(RESULT_BLOCK).addBlockMeta(tveci002.eiMetadata);
return inInfo;
}
/**
* 查询操作.
*/
@Override
public EiInfo query(EiInfo inInfo) {
/* 调用EI查询方法.*/
EiInfo outInfo = super.query(inInfo, "tveci002.query", new Tveci002());
return outInfo;
}
/**
* 新增操作.
*/
@Override
public EiInfo insert(EiInfo inInfo) {
try {
Tveci002 tveci002 = new Tveci002();
EiBlock eiBlock = inInfo.getBlock(RESULT_BLOCK);
for (int i = 0; i < eiBlock.getRowCount(); i++) {
Map<?, ?> map = eiBlock.getRow(i);
tveci002.fromMap(map);
this.dao.insert("tveci002.insert", tveci002.toMap());
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsg("新增成功!");
} catch (PlatException e) {
e.printStackTrace();
inInfo.setStatus(EiConstant.STATUS_FAILURE);
inInfo.setMsg("新增失败!原因参见详细错误描述!");
inInfo.setDetailMsg(e.getMessage());
logError("新增失败", e.getMessage());
return inInfo;
}
return inInfo;
}
/**
* 修改操作.
*/
public EiInfo update(EiInfo inInfo) {
try {
Tveci002 tveci002 = new Tveci002();
EiBlock eiBlock = inInfo.getBlock(RESULT_BLOCK);
for (int i = 0; i < eiBlock.getRowCount(); i++) {
Map<?, ?> map = eiBlock.getRow(i);
tveci002.fromMap(map);
this.dao.update("tveci002.update", tveci002.toMap());
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsg("修改成功!");
} catch (PlatException e) {
inInfo.setStatus(EiConstant.STATUS_FAILURE);
inInfo.setMsg("操作失败!原因参见详细错误描述!");
inInfo.setDetailMsg(e.getMessage());
logError("修改失败", e.getMessage());
return inInfo;
}
return query(inInfo);
}
/**
* 删除操作.
*/
public EiInfo delete(EiInfo eiInfo) {
Tveci002 tveci002 = new Tveci002();
EiBlock eiBlock = eiInfo.getBlock(RESULT_BLOCK);
try {
for (int i = 0; i < eiBlock.getRowCount(); i++) {
Map<?, ?> map = eiBlock.getRow(i);
tveci002.fromMap(map);
this.dao.delete("tveci002.delete", tveci002.toMap());
}
} catch (PlatException e) {
eiInfo.setStatus(EiConstant.STATUS_FAILURE);
eiInfo.setMsg("删除失败,原因参见详细错误描述!");
eiInfo.setDetailMsg(e.getMessage());
logError("删除失败!", e.getMessage());
return eiInfo;
}
eiInfo.setStatus(EiConstant.STATUS_SUCCESS);
eiInfo.setMsg("删除成功!");
return eiInfo;
}
}
<?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">
<!-- table information
Generate time : 2024-01-08 18:33:20
Version : 1.0
tableName :eplat.tveci002
RES_ID VARCHAR NOT NULL primarykey,
RES_CLASS VARCHAR NOT NULL primarykey,
HTML_CODE VARCHAR,
CSS_CODE VARCHAR,
JAVASCRIPT_CODE VARCHAR,
REC_CREATOR VARCHAR,
REC_CREATE_TIME VARCHAR,
REC_REVISOR VARCHAR,
REC_REVISE_TIME VARCHAR,
DEPENDENCIES VARCHAR
-->
<sqlMap namespace="tveci002">
<select id="query" parameterClass="java.util.HashMap"
resultClass="com.baosight.iplat4j.ee.dm.domain.Tveci002">
SELECT
RES_ID as "resId", <!-- 资源ID -->
RES_CLASS as "resClass", <!-- 资源类型 -->
HTML_CODE as "htmlCode", <!-- html代码 -->
CSS_CODE as "cssCode", <!-- 样式代码 -->
JAVASCRIPT_CODE as "javascriptCode", <!-- js代码 -->
REC_CREATOR as "recCreator", <!-- 创建人员 -->
REC_CREATE_TIME as "recCreateTime", <!-- 创建时间 -->
REC_REVISOR as "recRevisor", <!-- 更新人员 -->
REC_REVISE_TIME as "recReviseTime", <!-- 更新时间 -->
DEPENDENCIES as "dependencies" <!-- js依赖 -->
FROM eplat.tveci002 WHERE 1=1
<isNotEmpty prepend=" AND " property="resId">
RES_ID = #resId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="resClass">
RES_CLASS = #resClass#
</isNotEmpty>
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
$orderBy$
</isNotEmpty>
<isEmpty property="orderBy">
RES_ID asc,
RES_CLASS asc
</isEmpty>
</dynamic>
</select>
<select id="count" resultClass="int">
SELECT COUNT(*) FROM eplat.tveci002 WHERE 1=1
<isNotEmpty prepend=" AND " property="resId">
RES_ID = #resId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="resClass">
RES_CLASS = #resClass#
</isNotEmpty>
</select>
<!--
<isNotEmpty prepend=" AND " property="resId">
RES_ID = #resId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="resClass">
RES_CLASS = #resClass#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="htmlCode">
HTML_CODE = #htmlCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="cssCode">
CSS_CODE = #cssCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="javascriptCode">
JAVASCRIPT_CODE = #javascriptCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="recCreator">
REC_CREATOR = #recCreator#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="recCreateTime">
REC_CREATE_TIME = #recCreateTime#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="recRevisor">
REC_REVISOR = #recRevisor#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="recReviseTime">
REC_REVISE_TIME = #recReviseTime#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="dependencies">
DEPENDENCIES = #dependencies#
</isNotEmpty>
-->
<insert id="insert">
INSERT INTO eplat.tveci002 (RES_ID, <!-- 资源ID -->
RES_CLASS, <!-- 资源类型 -->
HTML_CODE, <!-- html代码 -->
CSS_CODE, <!-- 样式代码 -->
JAVASCRIPT_CODE, <!-- js代码 -->
REC_CREATOR, <!-- 创建人员 -->
REC_CREATE_TIME, <!-- 创建时间 -->
REC_REVISOR, <!-- 更新人员 -->
REC_REVISE_TIME, <!-- 更新时间 -->
DEPENDENCIES <!-- js依赖 -->
)
VALUES (#resId#, #resClass#, #htmlCode#, #cssCode#, #javascriptCode#, #recCreator#, #recCreateTime#, #recRevisor#, #recReviseTime#, #dependencies#)
</insert>
<delete id="delete">
DELETE FROM eplat.tveci002 WHERE
RES_ID = #resId# AND
RES_CLASS = #resClass#
</delete>
<update id="update">
UPDATE eplat.tveci002
SET
HTML_CODE = #htmlCode#, <!-- html代码 -->
CSS_CODE = #cssCode#, <!-- 样式代码 -->
JAVASCRIPT_CODE = #javascriptCode#, <!-- js代码 -->
REC_CREATOR = #recCreator#, <!-- 创建人员 -->
REC_CREATE_TIME = #recCreateTime#, <!-- 创建时间 -->
REC_REVISOR = #recRevisor#, <!-- 更新人员 -->
REC_REVISE_TIME = #recReviseTime#, <!-- 更新时间 -->
DEPENDENCIES = #dependencies# <!-- js依赖 -->
WHERE
RES_ID = #resId# AND
RES_CLASS = #resClass#
</update>
</sqlMap>
\ No newline at end of file
package com.baosight.hpjx.hp.constant;
/**
* @author:songx
* @date:2024/1/18,17:16
*/
public class HPConstant {
/**
* 序列号
*
* @author:songx
* @date:2021/8/17,15:22
*/
public class SequenceId {
// 用户ID
public static final String USER_ID = "USER_ID";
// 组织机构编码
public static final String ORG_CODE = "ORG_CODE";
// 组编码
public static final String GROUP_CODE = "GROUP_CODE";
// 厂区编码
public static final String FACTORY_CODE = "FACTORY_CODE";
// 企业编码
public static final String COMPANY_CODE = "COMPANY_CODE";
//项目档案编号
public static final String PROJ_NUMBER = "PROJ_NUMBER";
// 盘点单号
public static final String CHECK_NO = "STATISTICAL_NUMBER";
// 统计单号
public static final String HPKC008_NUMBER = "HPKC008_NUMBER";
// 巡检单号
public static final String HPZL001_NUMBER = "HPZL001_NUMBER";
//采购入库单号
public static final String HPKC001_NUMBER = "HPKC001_NUMBER";
//生产领料单号
public static final String HPKC002_NUMBER = "HPKC002_NUMBER";
// 生产入库单号
public static final String HPKC003_PROD_NO = "HPKC003_PROD_NO";
// 生产销售单号
public static final String HPKC004_SALE_NO = "HPKC004_SALE_NO";
// 供应商编码
public static final String HPPZ002_CUST_CODE = "HPPZ002_CUST_CODE";
// 客户编码
public static final String HPPZ003_CUST_CODE = "HPPZ003_CUST_CODE";
// 存货编码
public static final String INVENT_CODE = "INVENT_CODE";
// 仓库编码
public static final String WH_CODE = "WH_CODE";
// 其他入库单号
public static final String OTHER_ENTER_NO = "OTHER_ENTER_NO";
// 其他出库单号
public static final String OTHER_OUTER_NO = "OTHER_OUTER_NO";
//生产计划单
public static final String HPSC003_PROD_NO = "HPSC003_PROD_NO";
//生产订单
public static final String HPSC005_PROD_NO = "HPSC005_PROD_NO";
//生产任务订单
public static final String PROD_TASK_NO = "PROD_TASK_NO";
}
/**
* 库存类型
*
* @author:songx
* @date:2024/1/20,15:18
*/
public class KcType {
// 采购
public static final String CG = "CG";
// 生产
public static final String SC = "SC";
// 其他
public static final String QT = "QT";
}
/**
* 计划状态常量
*
* @author:songx
* @date:2024/2/22,13:57
*/
public static class planStatus {
// 计划中
public static final Integer S_0 = 0;
// 生产中
public static final Integer S_1 = 1;
}
}
package com.baosight.hpjx.hp.constant;
/**
* @author:songx
* @date:2024/1/18,17:16
*/
public class HPSqlConstant {
/**
* HPKC001 SQL 定义
*
* @author:songx
* @date:2024/1/20,16:45
*/
public class HPKC001 {
// 统计
public static final String STAT_DATE = "HPKC001.statDate";
// 锁
public static final String LOCK = "HPKC001.lock";
}
/**
* HPKC002 SQL 定义
*
* @author:songx
* @date:2024/1/20,16:45
*/
public class HPKC002 {
// 统计
public static final String STAT_DATE = "HPKC002.statDate";
// 锁
public static final String LOCK = "HPKC002.lock";
}
/**
* HPKC003 SQL 定义
*
* @author:songx
* @date:2024/1/20,16:45
*/
public class HPKC003 {
// 统计
public static final String STAT_DATE = "HPKC003.statDate";
// 锁
public static final String LOCK = "HPKC003.lock";
}
/**
* HPKC004 SQL 定义
*
* @author:songx
* @date:2024/1/20,16:45
*/
public class HPKC004 {
// 统计
public static final String STAT_DATE = "HPKC004.statDate";
// 锁
public static final String LOCK = "HPKC004.lock";
// 修改打印状态
public static final String UPDATE_PRINT = "HPKC004.updatePrint";
}
/**
* HPKC005 SQL 定义
*
* @author:songx
* @date:2024/1/20,16:45
*/
public class HPKC005 {
// 查询
public static final String QUERY_SUM = "HPKC005.querySum";
// 锁
public static final String LOCK = "HPKC005.lock";
// 统计
public static final String STAT_DATE = "HPKC005.statDate";
}
/**
* HPKC005A SQL 定义
*
* @author:songx
* @date:2024/1/20,16:45
*/
public class HPKC005A {
// 锁
public static final String LOCK = "HPKC005A.lock";
}
/**
* HPKC006 SQL 定义
*
* @author:songx
* @date:2024/1/20,16:45
*/
public class HPKC006 {
// 查询
public static final String QUERY_SUM = "HPKC006.querySum";
// 锁
public static final String LOCK = "HPKC006.lock";
// 统计
public static final String STAT_DATE = "HPKC006.statDate";
}
/**
* HPKC007 SQL 定义
*
* @author:songx
* @date:2024/1/20,16:45
*/
public class HPKC007 {
// 查询
public static final String QUERY_SUM = "HPKC007.querySum";
// 锁
public static final String LOCK = "HPKC007.lock";
// 统计
public static final String STAT_DATE = "HPKC007.statDate";
}
/**
* HPKC008 SQL 定义
*
* @author:songx
* @date:2024/1/20,16:45
*/
public class HPKC008 {
// 查询
public static final String QUERY_SUM = "HPKC008.querySum";
}
/**
* HPKC009 SQL 定义
*
* @author:songx
* @date:2024/1/20,16:45
*/
public class HPKC009 {
// 按日期删除
public static final String DELETE_BY_TIME = "HPKC009.deleteByTime";
// 查询
public static final String QUERY = "HPKC009.query";
// 查询统计
public static final String QUERY_SUM = "HPKC009.querySum";
}
/**
* HPKC009A SQL 定义
*
* @author:songx
* @date:2024/1/20,16:45
*/
public class HPKC009A {
// 按日期删除
public static final String DELETE_BY_TIME = "HPKC009A.deleteByTime";
// 查询
public static final String QUERY = "HPKC009A.query";
// 查询统计
public static final String QUERY_SUM = "HPKC009A.querySum";
}
/**
* HPKC010 SQL 定义
*
* @author:songx
* @date:2024/1/20,16:45
*/
public class HPKC010 {
// 锁
public static final String LOCK = "HPKC010.lock";
}
/**
* HPKC010A SQL 定义
*
* @author:songx
* @date:2024/1/20,16:45
*/
public class HPKC010A {
// 按日期删除
public static final String DELETE_BY_TIME = "HPKC010A.deleteByTime";
// 备份数量
public static final String BACKUP = "HPKC010A.backup";
}
/**
* HPKC011 SQL 定义
*
* @author:songx
* @date:2024/1/20,16:45
*/
public class HPKC011 {
// 锁
public static final String LOCK = "HPKC011.lock";
}
/**
* HPKC011A SQL 定义
*
* @author:songx
* @date:2024/1/20,16:45
*/
public class HPKC011A {
// 按日期删除
public static final String DELETE_BY_TIME = "HPKC011A.deleteByTime";
// 备份数量
public static final String BACKUP = "HPKC011A.backup";
}
/**
* HPKC012 SQL 定义
*
* @author:songx
* @date:2024/1/20,16:45
*/
public class HPKC012 {
// 锁
public static final String QUERY = "HPKC012.query";
}
/**
* HPKC013 SQL 定义
*
* @author:songx
* @date:2024/1/20,16:45
*/
public class HPKC013 {
// 锁
public static final String UPDATE_STATUS = "HPKC013.updateStatus";
}
/**
* HPPZ010 SQL 定义
*
* @author:songx
* @date:2024/1/18,17:17
*/
public class HPPZ010 {
// 新增
public static final String INSERT = "HPPZ010.insert";
// 查询
public static final String QUERY = "HPPZ010.query";
}
/**
* HPPZ011 SQL 定义
*
* @author:songx
* @date:2024/1/18,17:17
*/
public class HPPZ011 {
// 查询
public static final String GET = "HPPZ011.get";
}
/**
* HPPZ013 SQL 定义
*
* @author:songx
* @date:2024/1/18,17:17
*/
public class HPPZ013 {
// 修改
public static final String UPDATE = "HPPZ013.update";
// 修改状态
public static final String UPDATE_STATUS = "HPPZ013.updateStatus";
// 清空生产部门
public static final String CLEAR_GROUP = "HPPZ013.clearGroup";
// 清空生产厂区
public static final String CLEAR_FACTORY = "HPPZ013.clearFactory";
}
/**
* HPPZ014 SQL 定义
*
* @author:songx
* @date:2024/1/18,17:17
*/
public class HPPZ014 {
// 查询
public static final String UPDATE_TIME = "HPPZ014.updateTime";
}
/**
* HPSC003 SQL名称定义
*
* @author:songx
* @date:2024/2/5,10:16
*/
public class HPSC003 {
// 修改状态
public static final String UPDATE_STATUS = "HPSC003.updateStatus";
// 修改时间
public static final String UPDATE_DATE = "HPSC003.updateDate";
public static final String DELETE_BY_MAT = "HPSC003.deleteByMat";
}
/**
* HPSC004 SQL名称定义
*
* @author:songx
* @date:2024/2/5,10:16
*/
public class HPSC004 {
// 锁
public static final String LOCK = "HPSC004.lock";
// 根据材料号删除
public static final String DELETE_BY_MAT = "HPSC004.deleteByMat";
// 更新计划完工情况
public static final String UPDATE_PLAN_DATE = "HPSC004.updatePlanDate";
// 更新实际完工情况
public static final String UPDATE_COMPLETE = "HPSC004.updateComplete";
// 更新订单号
public static final String UPDATE_PROD_ORDER_NO = "HPSC004.updateProdOrderNo";
}
/**
* @author:songx
* @date:2024/2/5,10:16
*/
public class HPSC005 {
// 锁
public static final String LOCK = "HPSC005.lock";
// 查询
public static final String UPDATE_ASSIGN_NUM = "HPSC005.updateAssignNum";
public static final String DELETE_BY_MAT = "HPSC005.deleteByMat";
}
/**
* @author:songx
* @date:2024/2/5,10:16
*/
public class HPSC005A {
// 锁
public static final String LOCK = "HPSC005A.lock";
// 更新完成数量
public static final String UPDATE_COMPLETE_NUM = "HPSC005A.updateCompleteNum";
}
public class HPSC006 {
// 锁
public static final String LOCK = "HPSC006.lock";
// 更新完成数量
public static final String UPDATE_COMPLETE_NUM = "HPSC006.updateCompleteNum";
}
/**
* 质量巡检单
*
* @author:songx
* @date:2024/2/2,14:23
*/
public class HPZL001 {
// 已处理
public static final String DO_PROCESS = "HPZL001.doProcess";
// 已处理
public static final String DO_PROCESS2 = "HPZL001.doProcess2";
}
}
package com.baosight.hpjx.hp.ds.domain;
import com.baosight.iplat4j.core.util.NumberUtils;
import com.baosight.iplat4j.core.ei.EiColumn;
import com.baosight.iplat4j.core.data.DaoEPBase;
import java.util.HashMap;
import java.util.Map;
import com.baosight.iplat4j.core.util.StringUtils;
/**
* Project: <br>
* Title:SysOperationLog.java <br>
* Description: <br>
*
* Copyrigth:Baosight Software LTD.co Copyright (c) 2019. <br>
*
* @version 1.0
* @history 2024-03-04 15:58:48 create
*/
public class HPDS001 extends DaoEPBase {
private static final long serialVersionUID = 1L;
public static final String FIELD_ID = "id"; /* 主键id*/
public static final String FIELD_COMPANY_CODE = "companyCode"; /* 企业编码*/
public static final String FIELD_CREATED_BY = "createdBy"; /* 创建人*/
public static final String FIELD_CREATED_NAME = "createdName"; /* 创建人名称*/
public static final String FIELD_CREATED_TIME = "createdTime"; /* 创建时间*/
public static final String FIELD_OPER_MODUL = "operModul"; /* 操作模块*/
public static final String FIELD_OPER_TYPE = "operType"; /* 操作类型*/
public static final String FIELD_OPER_DESC = "operDesc"; /* 操作说明*/
public static final String FIELD_OPER_CONTENT = "operContent"; /* 操作内容*/
public static final String COL_ID = "ID"; /* 主键id*/
public static final String COL_COMPANY_CODE = "COMPANY_CODE"; /* 企业编码*/
public static final String COL_CREATED_BY = "CREATED_BY"; /* 创建人*/
public static final String COL_CREATED_NAME = "CREATED_NAME"; /* 创建人名称*/
public static final String COL_CREATED_TIME = "CREATED_TIME"; /* 创建时间*/
public static final String COL_OPER_MODUL = "OPER_MODUL"; /* 操作模块*/
public static final String COL_OPER_TYPE = "OPER_TYPE"; /* 操作类型*/
public static final String COL_OPER_DESC = "OPER_DESC"; /* 操作说明*/
public static final String COL_OPER_CONTENT = "OPER_CONTENT"; /* 操作内容*/
public static final String QUERY = "sys_operation_log.query";
public static final String COUNT = "sys_operation_log.count";
public static final String INSERT = "sys_operation_log.insert";
public static final String UPDATE = "sys_operation_log.update";
public static final String DELETE = "sys_operation_log.delete";
private Long id = new Long(0); /* 主键id*/
private String companyCode = " "; /* 企业编码*/
private String createdBy = " "; /* 创建人*/
private String createdName = " "; /* 创建人名称*/
private String createdTime = " "; /* 创建时间*/
private String operModul = " "; /* 操作模块*/
private String operType = " "; /* 操作类型*/
private String operDesc = " "; /* 操作说明*/
private String operContent = " "; /* 操作内容*/
/**
* initialize the metadata.
*/
public void initMetaData() {
EiColumn eiColumn;
eiColumn = new EiColumn(FIELD_ID);
eiColumn.setPrimaryKey(true);
eiColumn.setDescName("主键id");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_COMPANY_CODE);
eiColumn.setDescName("企业编码");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_CREATED_BY);
eiColumn.setDescName("创建人");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_CREATED_NAME);
eiColumn.setDescName("创建人名称");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_CREATED_TIME);
eiColumn.setDescName("创建时间");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_OPER_MODUL);
eiColumn.setDescName("操作模块");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_OPER_TYPE);
eiColumn.setDescName("操作类型");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_OPER_DESC);
eiColumn.setDescName("操作说明");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_OPER_CONTENT);
eiColumn.setDescName("操作内容");
eiMetadata.addMeta(eiColumn);
}
/**
* the constructor.
*/
public HPDS001() {
initMetaData();
}
/**
* get the id - 主键id.
* @return the id
*/
public Long getId() {
return this.id;
}
/**
* set the id - 主键id.
*
* @param id - 主键id
*/
public void setId(Long id) {
this.id = id;
}
/**
* get the companyCode - 企业编码.
* @return the companyCode
*/
public String getCompanyCode() {
return this.companyCode;
}
/**
* set the companyCode - 企业编码.
*
* @param companyCode - 企业编码
*/
public void setCompanyCode(String companyCode) {
this.companyCode = companyCode;
}
/**
* get the createdBy - 创建人.
* @return the createdBy
*/
public String getCreatedBy() {
return this.createdBy;
}
/**
* set the createdBy - 创建人.
*
* @param createdBy - 创建人
*/
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
/**
* get the createdName - 创建人名称.
* @return the createdName
*/
public String getCreatedName() {
return this.createdName;
}
/**
* set the createdName - 创建人名称.
*
* @param createdName - 创建人名称
*/
public void setCreatedName(String createdName) {
this.createdName = createdName;
}
/**
* get the createdTime - 创建时间.
* @return the createdTime
*/
public String getCreatedTime() {
return this.createdTime;
}
/**
* set the createdTime - 创建时间.
*
* @param createdTime - 创建时间
*/
public void setCreatedTime(String createdTime) {
this.createdTime = createdTime;
}
/**
* get the operModul - 操作模块.
* @return the operModul
*/
public String getOperModul() {
return this.operModul;
}
/**
* set the operModul - 操作模块.
*
* @param operModul - 操作模块
*/
public void setOperModul(String operModul) {
this.operModul = operModul;
}
/**
* get the operType - 操作类型.
* @return the operType
*/
public String getOperType() {
return this.operType;
}
/**
* set the operType - 操作类型.
*
* @param operType - 操作类型
*/
public void setOperType(String operType) {
this.operType = operType;
}
/**
* get the operDesc - 操作说明.
* @return the operDesc
*/
public String getOperDesc() {
return this.operDesc;
}
/**
* set the operDesc - 操作说明.
*
* @param operDesc - 操作说明
*/
public void setOperDesc(String operDesc) {
this.operDesc = operDesc;
}
/**
* get the operContent - 操作内容.
* @return the operContent
*/
public String getOperContent() {
return this.operContent;
}
/**
* set the operContent - 操作内容.
*
* @param operContent - 操作内容
*/
public void setOperContent(String operContent) {
this.operContent = operContent;
}
/**
* get the value from Map.
*
* @param map - source data map
*/
@Override
public void fromMap(Map map) {
setId(NumberUtils.toLong(StringUtils.toString(map.get(FIELD_ID)), id));
setCompanyCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_COMPANY_CODE)), companyCode));
setCreatedBy(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_CREATED_BY)), createdBy));
setCreatedName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_CREATED_NAME)), createdName));
setCreatedTime(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_CREATED_TIME)), createdTime));
setOperModul(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_OPER_MODUL)), operModul));
setOperType(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_OPER_TYPE)), operType));
setOperDesc(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_OPER_DESC)), operDesc));
setOperContent(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_OPER_CONTENT)), operContent));
}
/**
* set the value to Map.
*/
@Override
public Map toMap() {
Map map = new HashMap();
map.put(FIELD_ID, StringUtils.toString(id, eiMetadata.getMeta(FIELD_ID)));
map.put(FIELD_COMPANY_CODE, StringUtils.toString(companyCode, eiMetadata.getMeta(FIELD_COMPANY_CODE)));
map.put(FIELD_CREATED_BY, StringUtils.toString(createdBy, eiMetadata.getMeta(FIELD_CREATED_BY)));
map.put(FIELD_CREATED_NAME, StringUtils.toString(createdName, eiMetadata.getMeta(FIELD_CREATED_NAME)));
map.put(FIELD_CREATED_TIME, StringUtils.toString(createdTime, eiMetadata.getMeta(FIELD_CREATED_TIME)));
map.put(FIELD_OPER_MODUL, StringUtils.toString(operModul, eiMetadata.getMeta(FIELD_OPER_MODUL)));
map.put(FIELD_OPER_TYPE, StringUtils.toString(operType, eiMetadata.getMeta(FIELD_OPER_TYPE)));
map.put(FIELD_OPER_DESC, StringUtils.toString(operDesc, eiMetadata.getMeta(FIELD_OPER_DESC)));
map.put(FIELD_OPER_CONTENT, StringUtils.toString(operContent, eiMetadata.getMeta(FIELD_OPER_CONTENT)));
return map;
}
}
package com.baosight.hpjx.hp.ds.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.hp.ds.domain.HPDS001;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
/**
* Title: 历史数据清理 <br>
* @author LiuYang
* @version 1.0 2024/3/4
*/
public class ServiceHPDS001 extends ServiceEPBase {
@Override
@OperationLogAnnotation(operModul = "系统操作日志", operType = "页面初始化", operDesc = "初始化")
public EiInfo initLoad(EiInfo inInfo) {
return super.initLoad(inInfo);
}
@OperationLogAnnotation(operModul = "系统操作日志", operType = "删除", operDesc = "删除6个月之前的历史数据")
public EiInfo deleteHistory(EiInfo inInfo) {
return super.delete(inInfo,"HPDS001.deleteHistory");
}
}
package com.baosight.hpjx.hp.ds.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.sc.domain.HPSC002A;
import com.baosight.hpjx.util.DateUtils;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.iplat4j.core.ProjectInfo;
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.core.web.threadlocal.UserSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Title:文件备份 <br>
* @author LiuYang
* @version 1.0 2024/3/5
*/
public class ServiceHPDS002 extends ServiceEPBase {
@Override
public EiInfo initLoad(EiInfo inInfo) {
return super.initLoad(inInfo);
}
@Override
public EiInfo query(EiInfo inInfo) {
return super.query(inInfo);
}
@Override
@OperationLogAnnotation(operModul = "文件备份", operType = "删除", operDesc = "删除文件备份数据")
public EiInfo delete(EiInfo inInfo) {
return super.delete(inInfo);
}
@Override
@OperationLogAnnotation(operModul = "文件备份", operType = "修改", operDesc = "修改文件备份数据")
public EiInfo update(EiInfo inInfo) {
return super.update(inInfo);
}
@Override
@OperationLogAnnotation(operModul = "文件备份", operType = "新增", operDesc = "新增文件备份数据")
public EiInfo insert(EiInfo inInfo) {
try {
EiBlock block = inInfo.getBlock(EiConstant.resultBlock);
for (int i = 0; i < block.getRowCount(); i++) {
Map<String, Object> map = new HashMap<String, Object>(1);
map.put(HPSC002A.FIELD_DOC_ID, block.getCellStr(i, HPDS002.FIELD_DOC_ID));
//List<Map<String, Object>> list = this.dao.query("EUDM02.query", map);
HPDS002 hpds002 = new HPDS002();
hpds002.fromMap(block.getRow(i));
/*if (list.size() > 0) {
hpds002.setChgName(list.get(0).get("chgName").toString());
hpds002.setDirId(list.get(0).get("dirId").toString());
}*/
DaoUtils.insert(HPDS002.INSERT, hpds002);
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + block.getRowCount() + "]条数据新增成功!");
}catch (Exception e){
LogUtils.setDetailMsg(inInfo, e, "新增失败");
}
return inInfo;
}
}
<?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-03-04 15:58:48
Version : 1.0
schema : hpjx
tableName : SYS_OPERATION_LOG
ID BIGINT NOT NULL primarykey,
COMPANY_CODE VARCHAR NOT NULL,
CREATED_BY VARCHAR,
CREATED_NAME VARCHAR,
CREATED_TIME VARCHAR,
OPER_MODUL VARCHAR,
OPER_TYPE VARCHAR,
OPER_DESC VARCHAR,
OPER_CONTENT VARCHAR
-->
<sqlMap namespace="HPDS001">
<sql id="condition">
<isNotEmpty prepend=" AND " property="id">
ID = #id#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyCode">
COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdBy">
CREATED_BY = #createdBy#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdName">
CREATED_NAME = #createdName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdTime">
CREATED_TIME = #createdTime#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="operModul">
OPER_MODUL = #operModul#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="operType">
OPER_TYPE = #operType#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="operDesc">
OPER_DESC = #operDesc#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="operContent">
OPER_CONTENT = #operContent#
</isNotEmpty>
</sql>
<select id="query" parameterClass="java.util.HashMap"
resultClass="com.baosight.hpjx.hp.ds.domain.HPDS001">
SELECT
ID as "id", <!-- 主键id -->
COMPANY_CODE as "companyCode", <!-- 企业编码 -->
CREATED_BY as "createdBy", <!-- 创建人 -->
CREATED_NAME as "createdName", <!-- 创建人名称 -->
CREATED_TIME as "createdTime", <!-- 创建时间 -->
OPER_MODUL as "operModul", <!-- 操作模块 -->
OPER_TYPE as "operType", <!-- 操作类型 -->
OPER_DESC as "operDesc", <!-- 操作说明 -->
OPER_CONTENT as "operContent" <!-- 操作内容 -->
FROM ${hpjxSchema}.SYS_OPERATION_LOG WHERE 1=1
<include refid="condition" />
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
$orderBy$
</isNotEmpty>
<isEmpty property="orderBy">
ID asc
</isEmpty>
</dynamic>
</select>
<select id="count" resultClass="int">
SELECT COUNT(*) FROM ${hpjxSchema}.SYS_OPERATION_LOG WHERE 1=1
<include refid="condition" />
</select>
<!--
<isNotEmpty prepend=" AND " property="id">
ID = #id#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyCode">
COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdBy">
CREATED_BY = #createdBy#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdName">
CREATED_NAME = #createdName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdTime">
CREATED_TIME = #createdTime#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="operModul">
OPER_MODUL = #operModul#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="operType">
OPER_TYPE = #operType#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="operDesc">
OPER_DESC = #operDesc#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="operContent">
OPER_CONTENT = #operContent#
</isNotEmpty>
-->
<insert id="insert">
INSERT INTO ${hpjxSchema}.SYS_OPERATION_LOG (ID, <!-- 主键id -->
COMPANY_CODE, <!-- 企业编码 -->
CREATED_BY, <!-- 创建人 -->
CREATED_NAME, <!-- 创建人名称 -->
CREATED_TIME, <!-- 创建时间 -->
OPER_MODUL, <!-- 操作模块 -->
OPER_TYPE, <!-- 操作类型 -->
OPER_DESC, <!-- 操作说明 -->
OPER_CONTENT <!-- 操作内容 -->
)
VALUES (#id#, #companyCode#, #createdBy#, #createdName#, #createdTime#, #operModul#, #operType#, #operDesc#, #operContent#)
</insert>
<delete id="delete">
DELETE FROM ${hpjxSchema}.SYS_OPERATION_LOG WHERE
ID = #id#
</delete>
<!--删除6个月以前的历史数据-->
<delete id="deleteHistory">
delete from ${hpjxSchema}.SYS_OPERATION_LOG where left(CREATED_TIME,8) &lt;= DATE_FORMAT(DATE_SUB(CURDATE(), interval 6 month), '%Y%m%d')
</delete>
<update id="update">
UPDATE ${hpjxSchema}.SYS_OPERATION_LOG
SET
COMPANY_CODE = #companyCode#, <!-- 企业编码 -->
CREATED_BY = #createdBy#, <!-- 创建人 -->
CREATED_NAME = #createdName#, <!-- 创建人名称 -->
CREATED_TIME = #createdTime#, <!-- 创建时间 -->
OPER_MODUL = #operModul#, <!-- 操作模块 -->
OPER_TYPE = #operType#, <!-- 操作类型 -->
OPER_DESC = #operDesc#, <!-- 操作说明 -->
OPER_CONTENT = #operContent# <!-- 操作内容 -->
WHERE
ID = #id#
</update>
</sqlMap>
<?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"> <!-- table information
Generate time : 2024-03-06 16:14:16
Version : 1.0
schema : hpjx
tableName : TEUDM_TEMP
COMPANY_CODE VARCHAR NOT NULL primarykey,
DOC_ID VARCHAR NOT NULL primarykey,
DIR_ID VARCHAR NOT NULL,
DOC_NAME VARCHAR NOT NULL,
CHG_NAME VARCHAR NOT NULL,
DOC_SIZE DECIMAL NOT NULL,
DOC_TAG VARCHAR NOT NULL,
CREATED_BY VARCHAR NOT NULL,
CREATED_NAME VARCHAR NOT NULL,
CREATED_TIME VARCHAR NOT NULL,
UPDATED_BY VARCHAR NOT NULL,
UPDATED_NAME VARCHAR NOT NULL,
UPDATED_TIME VARCHAR NOT NULL,
ARCHIVE_FLAG VARCHAR NOT NULL,
REAL_PATH VARCHAR
-->
<sqlMap namespace="HPDS002">
<sql id="condition">
<isNotEmpty prepend=" AND " property="companyCode">
COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="docId">
DOC_ID = #docId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="docIds">
DOC_ID in $docIds$
</isNotEmpty>
<isNotEmpty prepend=" AND " property="dirId">
DIR_ID = #dirId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="docName">
DOC_NAME = #docName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="chgName">
CHG_NAME = #chgName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="docSize">
DOC_SIZE = #docSize#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="docTag">
DOC_TAG = #docTag#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdBy">
CREATED_BY = #createdBy#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdName">
CREATED_NAME = #createdName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdTime">
CREATED_TIME = #createdTime#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedBy">
UPDATED_BY = #updatedBy#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedName">
UPDATED_NAME = #updatedName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedTime">
UPDATED_TIME = #updatedTime#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="archiveFlag">
ARCHIVE_FLAG = #archiveFlag#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="realPath">
REAL_PATH = #realPath#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="bizType">
BIZ_TYPE = #bizType#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="matId">
MAT_ID = #matId#
</isNotEmpty>
</sql>
<select id="query" parameterClass="java.util.HashMap"
resultClass="com.baosight.hpjx.hp.ds.domain.HPDS002">
SELECT
COMPANY_CODE as "companyCode", <!-- 企业编码 -->
DOC_ID as "docId", <!-- 文件标识 -->
DIR_ID as "dirId", <!-- 目录标识 -->
DOC_NAME as "docName", <!-- 文件名 -->
CHG_NAME as "chgName", <!-- 物理文件名 -->
DOC_SIZE as "docSize", <!-- 文件大小 -->
DOC_TAG as "docTag", <!-- 文件标签 -->
CREATED_BY as "createdBy", <!-- 记录创建者 -->
CREATED_NAME as "createdName", <!-- 记录创建名称 -->
CREATED_TIME as "createdTime", <!-- 记录创建时间 -->
UPDATED_BY as "updatedBy", <!-- 记录修改者 -->
UPDATED_NAME as "updatedName", <!-- 记录修改名称 -->
UPDATED_TIME as "updatedTime", <!-- 记录修改时间 -->
ARCHIVE_FLAG as "archiveFlag", <!-- 同步标记 -->
REAL_PATH as "realPath", <!-- 物理路径 -->
BIZ_TYPE as "bizType",
MAT_ID as "matId"
FROM ${hpjxSchema}.TEUDM_TEMP WHERE 1=1
<include refid="condition" />
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
$orderBy$
</isNotEmpty>
<isEmpty property="orderBy">
COMPANY_CODE asc,
DOC_ID asc
</isEmpty>
</dynamic>
</select>
<select id="count" resultClass="int">
SELECT COUNT(*) FROM ${hpjxSchema}.TEUDM_TEMP WHERE 1=1
<include refid="condition" />
</select>
<!--
<isNotEmpty prepend=" AND " property="companyCode">
COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="docId">
DOC_ID = #docId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="dirId">
DIR_ID = #dirId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="docName">
DOC_NAME = #docName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="chgName">
CHG_NAME = #chgName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="docSize">
DOC_SIZE = #docSize#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="docTag">
DOC_TAG = #docTag#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdBy">
CREATED_BY = #createdBy#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdName">
CREATED_NAME = #createdName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdTime">
CREATED_TIME = #createdTime#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedBy">
UPDATED_BY = #updatedBy#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedName">
UPDATED_NAME = #updatedName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedTime">
UPDATED_TIME = #updatedTime#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="archiveFlag">
ARCHIVE_FLAG = #archiveFlag#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="realPath">
REAL_PATH = #realPath#
</isNotEmpty>
-->
<insert id="insert">
INSERT INTO ${hpjxSchema}.TEUDM_TEMP (
COMPANY_CODE, <!-- 企业编码 -->
DOC_ID, <!-- 文件标识 -->
DIR_ID, <!-- 目录标识 -->
DOC_NAME, <!-- 文件名 -->
CHG_NAME, <!-- 物理文件名 -->
DOC_SIZE, <!-- 文件大小 -->
DOC_TAG, <!-- 文件标签 -->
CREATED_BY, <!-- 记录创建者 -->
CREATED_NAME, <!-- 记录创建名称 -->
CREATED_TIME, <!-- 记录创建时间 -->
UPDATED_BY, <!-- 记录修改者 -->
UPDATED_NAME, <!-- 记录修改名称 -->
UPDATED_TIME, <!-- 记录修改时间 -->
ARCHIVE_FLAG, <!-- 同步标记 -->
REAL_PATH, <!-- 物理路径 -->
BIZ_TYPE,
MAT_ID
)
VALUES (#companyCode#, #docId#, #dirId#, #docName#, #chgName#, #docSize#, #docTag#, #createdBy#, #createdName#,
#createdTime#, #updatedBy#, #updatedName#, #updatedTime#, #archiveFlag#, #realPath#, #bizType#, #matId#)
</insert>
<delete id="delete">
DELETE FROM ${hpjxSchema}.TEUDM_TEMP WHERE
COMPANY_CODE = #companyCode#
<isNotEmpty prepend=" AND " property="docId">
DOC_ID = #docId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="docIds">
DOC_ID in $docIds$
</isNotEmpty>
<isNotEmpty prepend=" AND " property="bizType">
BIZ_TYPE = #bizType#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="matId">
MAT_ID = #matId#
</isNotEmpty>
</delete>
<update id="update">
UPDATE ${hpjxSchema}.TEUDM_TEMP
SET
DIR_ID = #dirId#, <!-- 目录标识 -->
DOC_NAME = #docName#, <!-- 文件名 -->
CHG_NAME = #chgName#, <!-- 物理文件名 -->
DOC_SIZE = #docSize#, <!-- 文件大小 -->
DOC_TAG = #docTag#, <!-- 文件标签 -->
CREATED_BY = #createdBy#, <!-- 记录创建者 -->
CREATED_NAME = #createdName#, <!-- 记录创建名称 -->
CREATED_TIME = #createdTime#, <!-- 记录创建时间 -->
UPDATED_BY = #updatedBy#, <!-- 记录修改者 -->
UPDATED_NAME = #updatedName#, <!-- 记录修改名称 -->
UPDATED_TIME = #updatedTime#, <!-- 记录修改时间 -->
ARCHIVE_FLAG = #archiveFlag#, <!-- 同步标记 -->
REAL_PATH = #realPath# <!-- 物理路径 -->
BIZ_TYPE = #bizType#
MAT_ID = #matId#
WHERE
COMPANY_CODE = #companyCode# AND
DOC_ID = #docId#
<isNotEmpty prepend=" AND " property="bizType">
BIZ_TYPE = #bizType#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="matId">
MAT_ID = #matId#
</isNotEmpty>
</update>
</sqlMap>
package com.baosight.hpjx.hp.ff.service;
import com.baosight.hpjx.common.HPConstants;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.hp.sc.domain.HPSC002;
import com.baosight.hpjx.hp.sc.domain.HPSC006;
import com.baosight.hpjx.hp.sc.tools.HPSCTools;
import com.baosight.hpjx.util.ExcelUtils;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ServiceHPFF001 extends ServiceEPBase {
/**
* 根据模板导入数据
*/
public EiInfo importDate(EiInfo inInfo) {
String fileName = inInfo.getString(HPConstants.PARAM_FILENAME);
String className = inInfo.getString(HPConstants.PARAM_CLASSNAME);
//解析文件,将文件中数据传入到inInfo中
switch (className){
/**
* 物料
*/
case "HPSC002":
String parentId = inInfo.getString("parentId");
String parentPrdtName = inInfo.getString("parentPrdtName");
String projCode = inInfo.getString("projCode");
String projName = inInfo.getString("projName");
int lv = inInfo.getInt("lv");
Map map = new HashMap<>();
map.put("parentId",parentId);
map.put("parentPrdtName",parentPrdtName);
map.put("projCode",projCode);
map.put("projName",projName);
map.put("lv",lv+1);
ExcelUtils.importFromExcel(inInfo, fileName,map, new HPSC002());
break;
case "HPSC006":
String projCode1 = inInfo.getString("projCode");
String projName1 = inInfo.getString("projName");
String productionOrderNo = inInfo.getString("productionOrderNo");
Map map1 = new HashMap<>();
map1.put("projCode",projCode1);
map1.put("projName",projName1);
map1.put("productionOrderNo",productionOrderNo);
map1.put("inventType","7");
ExcelUtils.importFromExcel(inInfo, fileName,map1, new HPSC006());
inInfo = this.refreshHPSC006(inInfo, productionOrderNo);
}
return inInfo;
}
private EiInfo refreshHPSC006(EiInfo inInfo, String productionOrderNo) {
List<HPSC006> HPSC006 = HPSCTools.Hpsc006.get(productionOrderNo);
inInfo.addBlock(CommonConstant.Field.DETAIL).addRows(HPSC006);
return inInfo;
}
}
package com.baosight.hpjx.hp.kc.domain;
import com.baosight.iplat4j.core.data.DaoEPBase;
import com.baosight.iplat4j.core.ei.EiColumn;
import com.baosight.iplat4j.core.util.NumberUtils;
import com.baosight.iplat4j.core.util.StringUtils;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
/**
* Project: <br>
* Title:THpkc010.java <br>
* Description: <br>
*
* Copyrigth:Baosight Software LTD.co Copyright (c) 2019. <br>
*
* @version 1.0
* @history 2024-01-25 17:57:24 create
*/
public class HPKC012 extends HPKC010 {
private static final long serialVersionUID = 1L;
public static final String FIELD_WARN_NUM = "warnNum"; /* 预警数量*/
public static final String FIELD_PRINC = "princ"; /* 负责人*/
public static final String COL_WARN_NUM = "WARN_NUM"; /* 预警数量*/
public static final String COL_PRINC = "PRINC"; /* 负责人*/
public static final String QUERY = "HPKC012.query";
private BigDecimal warnNum = new BigDecimal("0"); /* 预警数量*/
private String princ = " "; /* 负责人*/
/**
* initialize the metadata.
*/
public void initMetaData() {
EiColumn eiColumn;
eiColumn = new EiColumn(FIELD_WARN_NUM);
eiColumn.setType("N");
eiColumn.setScaleLength(0);
eiColumn.setFieldLength(12);
eiColumn.setDescName("预警数量");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_PRINC);
eiColumn.setDescName("负责人");
eiMetadata.addMeta(eiColumn);
}
/**
* the constructor.
*/
public HPKC012() {
super.initMetaData();
initMetaData();
}
/**
* get the warnNum - 预警数量.
* @return the warnNum
*/
public BigDecimal getWarnNum() {
return this.warnNum;
}
/**
* set the warnNum - 预警数量.
*
* @param warnNum - 预警数量
*/
public void setWarnNum(BigDecimal warnNum) {
this.warnNum = warnNum;
}
/**
* get the value from Map.
*
* @param map - source data map
*/
/**
* get the princ - 负责人.
* @return the princ
*/
public String getPrinc() {
return this.princ;
}
/**
* set the princ - 负责人.
*
* @param princ - 负责人
*/
public void setPrinc(String princ) {
this.princ = princ;
}
@Override
public void fromMap(Map map) {
super.fromMap(map);
setWarnNum(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_WARN_NUM)), warnNum));
setPrinc(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_PRINC)), princ));
}
/**
* set the value to Map.
*/
@Override
public Map toMap() {
Map map = super.toMap();
map.put(FIELD_WARN_NUM, StringUtils.toString(warnNum, eiMetadata.getMeta(FIELD_WARN_NUM)));
map.put(FIELD_PRINC, StringUtils.toString(princ, eiMetadata.getMeta(FIELD_PRINC)));
return map;
}
}
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.hp.constant.HPConstant;
import com.baosight.hpjx.hp.kc.domain.HPKC001;
import com.baosight.hpjx.hp.kc.tools.HPKCTools;
import com.baosight.hpjx.hp.pz.domain.HPPZ006;
import com.baosight.hpjx.hp.pz.tools.HPPZTools;
import com.baosight.hpjx.util.AssertUtils;
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.hpjx.util.StringUtils;
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.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 YK
* @date 2024年01月09日 10:18
*/
public class ServiceHPKC001 extends ServiceBase {
// 指定存货类型
private static final Integer[] DEFAULT_INVENT_CODE = {InventTypeEnum.RAW.getCode(),
InventTypeEnum.CONSUMABLE.getCode()};
/**
* 画面初始化
*
* @param inInfo
* @return
*/
@Override
@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.SPEC_NAME_BLOCK_ID), queryMap);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.INVENT_ALL_BLOCK_ID), queryMap, false);
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HPKC001().eiMetadata);
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
/**
* 查询操作
*
* @param inInfo
* @return
*/
@Override
@OperationLogAnnotation(operModul = "采购入库单", operType = "查询", operDesc = "查询")
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, HPKC001.QUERY, new HPKC001());
// List sum = dao.query(HPSqlConstant.HPKC001.QUERY_SUM, queryRow);
// inInfo.getBlock(EiConstant.resultBlock).set(EiConstant.COLUMN_TOTAL_SUM, sum.get(0));
// 设置规格信息
HPPZTools.HpPz006.setSpecInfo(inInfo, HPKC001.FIELD_INVENT_RECORD_ID);
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
return inInfo;
}
/**
* 保存操作.
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "采购入库单", operType = "插入", operDesc = "保存")
public EiInfo save(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 数据校验
this.checkSaveData(resultRows);
// 写入数据
this.saveData(resultRows);
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
/**
* 保存数据
*
* @param resultRows
*/
private void saveData(List<Map> resultRows) {
for (Map resultRow : resultRows) {
HPKC001 fKc001 = new HPKC001();
fKc001.fromMap(resultRow);
HPPZ006 fPz006 = new HPPZ006();
fPz006.fromMap(resultRow);
if (fKc001.getId() == null || fKc001.getId() == 0) {
this.addData(fKc001, fPz006);
} else {
// TODO 采购入库不支持修改
}
}
}
/**
* 写入数据
*
* @param fKc001
* @param fPz006
*/
private void addData(HPKC001 fKc001, HPPZ006 fPz006) {
// 设置基础信息
this.setBaseInfo(fKc001);
// 检查存货名称是新增还是已存在
if (StringUtils.isBlank(fKc001.getInventCode())) {
String inventCode = HPPZTools.HpPz004.checkAndSave(fKc001.getInventType(), fKc001.getInventName());
fKc001.setInventCode(inventCode);
fPz006.setInventCode(inventCode);
}
// 检查规格是否已存在,不存在就新增
HPPZ006 dbPz006 = HPPZTools.HpPz006.checkAndSave(fPz006);
fKc001.setInventRecordId(dbPz006.getId());
// 计算重量
this.calcWeight(fKc001);
// 生成入库单号
fKc001.setPurchaseNo(SequenceGenerator.getNextSequence(HPConstant.SequenceId.HPKC001_NUMBER));
fKc001.setDeleteFlag(CommonConstant.YesNo.NO_0);
DaoUtils.insert(HPKC001.INSERT, fKc001);
// 修改库存
HPKCTools.updateStock(fKc001.getWhCode(), fKc001.getInventRecordId(), fKc001.getAmount(),
fKc001.getUnitWeight(), fKc001.getWeight());
}
/**
* 校验保存的数据
*
* @param resultRows
*/
private void checkSaveData(List<Map> resultRows) {
for (Map resultRow : resultRows) {
HPKC001 fKc001 = new HPKC001();
fKc001.fromMap(resultRow);
AssertUtils.isEmpty(fKc001.getWhCode(), "仓库名称不能为空");
// AssertUtils.isEmpty(fKc001.getInventCode(), "存货名称不能为空");
AssertUtils.isGt(BigDecimal.ZERO, fKc001.getAmount(), "数量必须大于0");
}
}
/**
* 设置基础信息
*
* @param fKc001
*/
private void setBaseInfo(HPKC001 fKc001) {
// 去除日期字符串中的-
fKc001.setReceiptDate(StringUtil.removeHorizontalLine(fKc001.getReceiptDate()));
// 仓库名称
fKc001.setWhName(HPPZTools.HpPz007.getByCode(fKc001.getWhCode()).getWhName());
// 存货名称
// fKc001.setInventName(HPPZTools.HpPz004.getByCode(fKc001.getInventCode()).getInventName());
}
/**
* 计算重量
*
* @param fKc001
*/
private void calcWeight(HPKC001 fKc001) {
// 根据规格计算单重
fKc001.setUnitWeight(HPPZTools.HpPz006.calcUnitWeight(fKc001.getInventRecordId()));
// 计算总重
fKc001.setWeight(fKc001.getAmount().multiply(fKc001.getUnitWeight()));
}
/**
* 删除操作intCompact = 14040
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "采购入库单", operType = "删除", operDesc = "删除")
public EiInfo delete(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 入库单号
List<String> otherEnterNos = ObjectUtils.listKey(resultRows, "otherEnterNo");
// 锁记录
HPKCTools.HpKc001. lock(otherEnterNos);
// 查询数据库记录
Map<String, HPKC001> mapKc001 = HPKCTools.HpKc001.map(otherEnterNos);
// 删除数据
this.deleteData(resultRows, mapKc001);
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据删除成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "删除失败");
}
return inInfo;
}
/**
* 删除数据
*
* @param resultRows
* @param mapKc001
*/
private void deleteData(List<Map> resultRows, Map<String, HPKC001> mapKc001) {
for (Map resultRow : resultRows) {
HPKC001 fKc001 = new HPKC001();
fKc001.fromMap(resultRow);
DaoUtils.update(HPKC001.DELETE, fKc001);
// 生成红冲记录
HPKC001 dbKc001 = mapKc001.get(fKc001.getPurchaseNo());
HPKC001 newKc006 = BeanUtils.copy(dbKc001, HPKC001.class);
newKc006.setPurchaseNo(SequenceGenerator.getNextSequence(HPConstant.SequenceId.OTHER_ENTER_NO));
newKc006.setAmount(newKc006.getAmount().negate());
newKc006.setWeight(newKc006.getWeight().negate());
newKc006.setOldPurchaseNo(newKc006.getPurchaseNo());
newKc006.setDeleteFlag(CommonConstant.YesNo.YES_1);
DaoUtils.insert(HPKC001.INSERT, newKc006);
// 修改库存
HPKCTools.updateStock(dbKc001.getWhCode(), dbKc001.getInventRecordId(), dbKc001.getAmount().negate(),
dbKc001.getUnitWeight(), dbKc001.getWeight().negate());
}
}
}
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.hp.constant.HPConstant;
import com.baosight.hpjx.hp.kc.domain.HPKC002;
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.exception.PlatException;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import org.apache.commons.collections.MapUtils;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author:songx
* @date:2024/1/25,23:19
*/
public class ServiceHPKC002 extends ServiceBase {
// 指定存货类型
private static final Integer[] DEFAULT_INVENT_CODE = {InventTypeEnum.RAW.getCode(),
InventTypeEnum.CONSUMABLE.getCode()};
/**
* 画面初始化.
*/
@OperationLogAnnotation(operModul = "生产领料单",operType = "查询",operDesc = "初始化")
@Override
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.PROJ_RECORD_BLOCK_ID), null, false);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.INVENT_ALL_BLOCK_ID), queryMap, false);
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HPKC002().eiMetadata);
inInfo.setBlock(InventTypeEnum.generatorEiBlock());
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
/**
* 查询操作
*
* @param inInfo
* @return
*/
@Override
@OperationLogAnnotation(operModul = "生产领料单",operType = "查询",operDesc = "查询")
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, HPKC002.QUERY, new HPKC002());
} 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> reqNos = ObjectUtils.listKey(resultRows, "reqNo");
// 锁记录
HPKCTools.HpKc002.lock(reqNos);
// 查询数据库记录
Map<String, HPKC002> dbMapKc002 = HPKCTools.HpKc002.map(reqNos);
for (int i = 0; i < resultRows.size(); i++) {
HPKC002 fKc002 = new HPKC002();
fKc002.fromMap(resultRows.get(i));
DaoUtils.update(HPKC002.DELETE, fKc002);
// 生成红冲记录
HPKC002 dbKc002 = dbMapKc002.get(fKc002.getReqNo());
HPKC002 newKc002 = BeanUtils.copy(dbKc002, HPKC002.class);
newKc002.setReqNo(SequenceGenerator.getNextSequence(HPConstant.SequenceId.HPKC002_NUMBER));
newKc002.setAmount(dbKc002.getAmount().negate());
newKc002.setWeight(dbKc002.getWeight().negate());
newKc002.setProjCode(dbKc002.getProjCode());
newKc002.setHpsc006Id(dbKc002.getHpsc006Id());
newKc002.setOldReqNo(dbKc002.getReqNo());
newKc002.setDeleteFlag(CommonConstant.YesNo.YES_1);
DaoUtils.insert(HPKC002.INSERT, newKc002);
// 修改库存
HPKCTools.updateStock(dbKc002.getWhCode(), dbKc002.getInventRecordId(),
dbKc002.getAmount(), dbKc002.getUnitWeight(), dbKc002.getWeight());
}
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.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.constant.HPConstant;
import com.baosight.hpjx.hp.kc.domain.HPKC002;
import com.baosight.hpjx.hp.kc.domain.HPKC010;
import com.baosight.hpjx.hp.kc.tools.HPKCTools;
import com.baosight.hpjx.hp.sc.domain.HPSC001;
import com.baosight.hpjx.hp.sc.domain.HPSC005;
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.hpjx.hp.sc.domain.HPSC006;
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.service.impl.ServiceEPBase;
import com.baosight.iplat4j.core.util.NumberUtils;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import java.math.BigDecimal;
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 ServiceHPKC002A extends ServiceEPBase {
// 指定存货类型
private static final Integer[] DEFAULT_INVENT_CODE = {InventTypeEnum.RAW.getCode(),
InventTypeEnum.CONSUMABLE.getCode()};
/**
* 初始化
*
* @param inInfo
* @return
*/
@Override
@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.SPEC_NAME_BLOCK_ID), queryMap, false);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.PROJ_RECORD_BLOCK_ID), null, false);
String hpsc006Id = inInfo.getString("inqu_status-0-hpsc006Id");
if (StringUtils.isNotBlank(hpsc006Id)) {
inInfo.set("inqu_result-0-hpsc006Id", hpsc006Id);
}
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HPKC010().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 queryRow = EiInfoUtils.getFirstRow(inInfo);
queryRow.put("inventTypes", DEFAULT_INVENT_CODE);
inInfo = super.query(inInfo, HPKC010.QUERY, new HPKC010());
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
return inInfo;
}
/**
* 生成出库单
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "库存查询",operType = "插入",operDesc = "生产领料单-库存查询-生成出库单")
public EiInfo select(EiInfo inInfo) {
try {
String hpsc006Id = inInfo.getString("inqu_result-0-hpsc006Id");
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 库存ID
List<Long> ids = ObjectUtils.listKey(resultRows, "id");
// 行锁
HPKCTools.HpKc010.lock(ids);
// 获取库存信息
Map<Long, HPKC010> dbKc010Map = HPKCTools.HpKc010.map(ids);
// 状态校验
this.checkData(resultRows, dbKc010Map);
// 生成销售库单
this.saveData(resultRows, dbKc010Map, hpsc006Id);
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "生成领料单失败");
}
return inInfo;
}
/**
* 数据校验
*
* @param resultRows
* @param dbKc010Map
*/
private void checkData(List<Map> resultRows, Map<Long, HPKC010> dbKc010Map) {
for (Map row : resultRows) {
Long id = MapUtils.getLong(row, "id");
HPKC010 dbKc010 = dbKc010Map.get(id);
AssertUtils.isNull(dbKc010, "库存号[" + id + "]不存在!");
// 校验数量
BigDecimal applyAmount = MapUtils.getBigDecimal(row, "applyAmount");
AssertUtils.isGt(applyAmount, dbKc010.getAmount(),
"库存号[" + id + "]可用数量不足!");
}
}
/**
* 保存数据
*
* @param resultRows
* @param dbKc010Map
*/
private void saveData(List<Map> resultRows, Map<Long, HPKC010> dbKc010Map, String hpsc006Id) {
for (Map row : resultRows) {
BigDecimal applyAmount = MapUtils.getBigDecimal(row, "applyAmount");
String applyRemark = MapUtils.getString(row, "applyRemark");
String projCode = MapUtils.getString(row, "projCode");
Long kcId = MapUtils.getLong(row, "id");
HPKC010 dbKc010 = dbKc010Map.get(kcId);
HPKC002 newKc002 = BeanUtils.copy(dbKc010, HPKC002.class);
newKc002.setReqNo(SequenceGenerator.getNextSequence(HPConstant.SequenceId.HPKC002_NUMBER));
newKc002.setReceiptDate(DateUtils.shortDate());
newKc002.setAmount(applyAmount);
newKc002.setWeight(dbKc010.getUnitWeight().multiply(applyAmount));
newKc002.setRemark(applyRemark);
newKc002.setKcId(kcId);
newKc002.setDeleteFlag(CommonConstant.YesNo.NO_0);
if (StringUtils.isNotBlank(hpsc006Id)) {
HPSC006 HPSC006 = HPSCTools.Hpsc006.getById(NumberUtils.toLong(hpsc006Id));
newKc002.setHpsc006Id(HPSC006.getId());
newKc002.setProjCode(HPSC006.getProjCode());
}else{
newKc002.setProjCode(projCode);
}
DaoUtils.insert(HPKC002.INSERT, newKc002);
// 修改库存数量
HPKCTools.updateStock(newKc002.getWhCode(), newKc002.getInventRecordId(),
newKc002.getAmount().negate(), dbKc010.getUnitWeight(), newKc002.getWeight().negate());
}
}
}
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.constant.HPConstant;
import com.baosight.hpjx.hp.kc.domain.HPKC002;
import com.baosight.hpjx.hp.kc.domain.HPKC010;
import com.baosight.hpjx.hp.kc.tools.HPKCTools;
import com.baosight.hpjx.hp.sc.domain.HPSC006;
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.service.impl.ServiceEPBase;
import com.baosight.iplat4j.core.util.NumberUtils;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import java.math.BigDecimal;
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 ServiceHPKC002B extends ServiceEPBase {
// 指定存货类型
private static final Integer[] DEFAULT_INVENT_CODE = {InventTypeEnum.RAW.getCode(),
InventTypeEnum.CONSUMABLE.getCode()};
/**
* 初始化
*
* @param inInfo
* @return
*/
@Override
@OperationLogAnnotation(operModul = "库存查询", operType = "查询", operDesc = "生产领料单-库存查询-初始化")
public EiInfo initLoad(EiInfo inInfo) {
try {
Map queryMap = new HashMap();
queryMap.put("inventTypes", DEFAULT_INVENT_CODE);
Map queryMap2 = new HashMap();
queryMap2.put("companyCode", UserSessionUtils.getCompanyCode());
queryMap2.put("status", 1);
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.SPEC_NAME_BLOCK_ID), queryMap, false);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.PROJ_RECORD_BLOCK_ID), queryMap2, false);
String hpsc006Id = inInfo.getString("inqu_status-0-hpsc006Id");
if (StringUtils.isNotBlank(hpsc006Id)) {
inInfo.set("inqu_result-0-hpsc006Id", hpsc006Id);
}
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HPKC010().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 queryRow = EiInfoUtils.getFirstRow(inInfo);
queryRow.put("inventTypes", DEFAULT_INVENT_CODE);
inInfo = super.query(inInfo, HPKC010.QUERY, new HPKC010());
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
return inInfo;
}
/**
* 生成出库单
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "库存查询",operType = "插入",operDesc = "生产领料单-库存查询-生成出库单")
public EiInfo select(EiInfo inInfo) {
try {
String hpsc006Id = inInfo.getString("inqu_result-0-hpsc006Id");
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 库存ID
List<Long> ids = ObjectUtils.listKey(resultRows, "id");
// 行锁
HPKCTools.HpKc010.lock(ids);
// 获取库存信息
Map<Long, HPKC010> dbKc010Map = HPKCTools.HpKc010.map(ids);
// 状态校验
this.checkData(resultRows, dbKc010Map);
// 生成销售库单
this.saveData(resultRows, dbKc010Map, hpsc006Id);
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "生成领料单失败");
}
return inInfo;
}
/**
* 数据校验
*
* @param resultRows
* @param dbKc010Map
*/
private void checkData(List<Map> resultRows, Map<Long, HPKC010> dbKc010Map) {
for (Map row : resultRows) {
Long id = MapUtils.getLong(row, "id");
HPKC010 dbKc010 = dbKc010Map.get(id);
AssertUtils.isNull(dbKc010, "库存号[" + id + "]不存在!");
// 校验数量
BigDecimal applyAmount = MapUtils.getBigDecimal(row, "applyAmount");
AssertUtils.isGt(applyAmount, dbKc010.getAmount(),
"库存号[" + id + "]可用数量不足!");
}
}
/**
* 保存数据
*
* @param resultRows
* @param dbKc010Map
*/
private void saveData(List<Map> resultRows, Map<Long, HPKC010> dbKc010Map, String hpsc006Id) {
for (Map row : resultRows) {
BigDecimal applyAmount = MapUtils.getBigDecimal(row, "applyAmount");
String applyRemark = MapUtils.getString(row, "applyRemark");
String projCode = MapUtils.getString(row, "projCode");
Long kcId = MapUtils.getLong(row, "id");
HPKC010 dbKc010 = dbKc010Map.get(kcId);
HPKC002 newKc002 = BeanUtils.copy(dbKc010, HPKC002.class);
newKc002.setReqNo(SequenceGenerator.getNextSequence(HPConstant.SequenceId.HPKC002_NUMBER));
newKc002.setReceiptDate(DateUtils.shortDate());
newKc002.setAmount(applyAmount);
newKc002.setWeight(dbKc010.getUnitWeight().multiply(applyAmount));
newKc002.setRemark(applyRemark);
newKc002.setKcId(kcId);
newKc002.setDeleteFlag(CommonConstant.YesNo.NO_0);
if (StringUtils.isNotBlank(hpsc006Id)) {
HPSC006 HPSC006 = HPSCTools.Hpsc006.getById(NumberUtils.toLong(hpsc006Id));
newKc002.setHpsc006Id(HPSC006.getId());
newKc002.setProjCode(HPSC006.getProjCode());
}else{
newKc002.setProjCode(projCode);
}
DaoUtils.insert(HPKC002.INSERT, newKc002);
// 修改库存数量
HPKCTools.updateStock(newKc002.getWhCode(), newKc002.getInventRecordId(),
newKc002.getAmount().negate(), dbKc010.getUnitWeight(), newKc002.getWeight().negate());
}
}
}
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.constant.HPSqlConstant;
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.HPSC004;
import com.baosight.hpjx.hp.sc.tools.HPSCTools;
import com.baosight.hpjx.hp.zl.domain.HPZL001;
import com.baosight.hpjx.hp.zl.tools.HPZLTools;
import com.baosight.hpjx.util.AssertUtils;
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.EiBlock;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import com.baosight.iplat4j.core.util.DateUtils;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import org.apache.commons.collections.MapUtils;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* @author:songx
* @date:2024/1/22,10:48
*/
public class ServiceHPKC003 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[]{"2","3"});}}, false);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.INVENT_NAME_BLOCK_ID), null);
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HPKC003().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, "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, "查询失败");
}
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(),
newKc003.getAmount(), newKc003.getWeight());
}
eiInfo.setStatus(EiConstant.STATUS_SUCCESS);
eiInfo.setMsg("删除成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(eiInfo, e, "删除失败");
}
return eiInfo;
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
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