|
|
@@ -3,8 +3,8 @@ package com.uas.eis.serviceImpl;
|
|
|
import com.uas.eis.core.config.SpObserver;
|
|
|
import com.uas.eis.dao.BaseDao;
|
|
|
import com.uas.eis.dao.SqlRowList;
|
|
|
-import com.uas.eis.dto.DataCenter;
|
|
|
import com.uas.eis.entity.ErrorMessage;
|
|
|
+import com.uas.eis.entity.ProdBindSetRequest;
|
|
|
import com.uas.eis.exception.ApiSystemException;
|
|
|
import com.uas.eis.sdk.entity.ApiResult;
|
|
|
import com.uas.eis.sdk.resp.ApiResponse;
|
|
|
@@ -14,13 +14,14 @@ import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Propagation;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.sql.Timestamp;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
-import java.util.logging.Logger;
|
|
|
|
|
|
@Service
|
|
|
public class MESDataServiceImpl implements MESDataService {
|
|
|
@@ -542,8 +543,96 @@ public class MESDataServiceImpl implements MESDataService {
|
|
|
}
|
|
|
}
|
|
|
return ApiResponse.successRsp("0",requestId,"操作成功");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @add xiaost 2026-06-01
|
|
|
+ * 设置产品SN强制绑定项
|
|
|
+ * @param jsonData
|
|
|
+ * * .{
|
|
|
+ * * ."code": "PRODBINDSET",
|
|
|
+ * * ."data":{
|
|
|
+ * * . "type":"ADD",
|
|
|
+ * * . "ss_mothercode":"01.EL0.PR68M06030A",
|
|
|
+ * * . "detail":[{
|
|
|
+ * * . "ss_detno": 1,
|
|
|
+ * * . "ss_prodcode":"01.ER0.60R4J02010A",
|
|
|
+ * * . "ss_prdetail":"主板 PCBA",
|
|
|
+ * * . "ss_repcodes":"",
|
|
|
+ * * . "ss_stepcode":"B_AOIB",
|
|
|
+ * * . "ss_stepname":"AOIB"
|
|
|
+ * * . }]
|
|
|
+ * * . }
|
|
|
+ * * .}
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ApiResult<Map<Object, Object>> prodBindSet(String accessKey, String requestId, ProdBindSetRequest reqData,String jsonData) {
|
|
|
+ String AE_MASTER = checkAccessKey(accessKey, requestId);
|
|
|
+ SpObserver.putSp(AE_MASTER); //切换数据源
|
|
|
+ //保存传参数据原始JSON串,记录日志
|
|
|
+ savelog("设置产品SN强制绑定项",jsonData,accessKey,requestId);
|
|
|
+ return ApiResponse.successRsp("0",requestId,"操作成功");
|
|
|
+ //执行业务操作
|
|
|
+ //return executeSNBindSet(accessKey,requestId,reqData);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /*@Transactional
|
|
|
+ public ApiResult<Map<Object, Object>> executeSNBindSet(String accessKey, String requestId, ProdBindSetRequest reqData){
|
|
|
+ String type = reqData.getData().getType();
|
|
|
+ String ss_mothercode = reqData.getData().getSs_mothercode();
|
|
|
+ List<ProdBindSetRequest.DetailDTO> detailList = reqData.getData().getDetail();
|
|
|
+ // 业务规则:ADD 时要求 detail 中每个元素的特定字段已存在(其实已在DTO中校验,此处可省略)
|
|
|
+ // 但如果有更复杂的跨字段规则(例如 ss_detno 必须大于0),可以在这里补充
|
|
|
+ long ss_id = 0;
|
|
|
+ SqlRowList rs = baseDao.queryForRowSet("select * from SNBINDSET where ss_mothercode=?",ss_mothercode);
|
|
|
+ if(rs.next()){
|
|
|
+ ss_id = rs.getGeneralLong("ss_id");
|
|
|
+ }
|
|
|
+ List<String> sql = new ArrayList<>();
|
|
|
+ if ("ADD".equals(type)) { //新增或者修改
|
|
|
+ if(ss_id>0){ //存在则删除
|
|
|
+ baseDao.execute("delete from SNBINDSET where ss_mothercode=?",ss_mothercode);
|
|
|
+ }
|
|
|
+ if (detailList == null || detailList.isEmpty()) {
|
|
|
+ return ApiResponse.failRsp(ErrorMessage.BUSINESS_ILLEGAL.getCode(), requestId, "ADD操作时detail不能为空");
|
|
|
+ }
|
|
|
+ // 2. 批量插入新数据
|
|
|
+ String insertSql = "INSERT INTO snbindset (ss_id,ss_mothercode, ss_detno, ss_prodcode, ss_prdetail," +
|
|
|
+ " ss_repcodes, ss_stepcode, ss_stepname,ss_indate) " +
|
|
|
+ "VALUES (snbindset_seq.nextval,?, ?, ?, ?, ?, ?, ?,sysdate)";
|
|
|
+ List<Object[]> batchArgs = new ArrayList<>();
|
|
|
+ int i =1;
|
|
|
+ for (ProdBindSetRequest.DetailDTO detail : detailList) {
|
|
|
+ batchArgs.add(new Object[]{
|
|
|
+ ss_mothercode,
|
|
|
+ i,
|
|
|
+ detail.getSs_prodcode(),
|
|
|
+ detail.getSs_prdetail(),
|
|
|
+ detail.getSs_repcodes(),
|
|
|
+ detail.getSs_stepcode(),
|
|
|
+ detail.getSs_stepname()
|
|
|
+ });
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ baseDao.getJdbcTemplate().batchUpdate(insertSql, batchArgs);
|
|
|
+ } else if ("DEL".equals(type)) {
|
|
|
+ if(ss_id == 0){
|
|
|
+ return ApiResponse.failRsp(ErrorMessage.BUSINESS_ILLEGAL.getCode(), requestId, "错误,当前产品编号:"+ss_mothercode+",未设置绑定项,不需要删除");
|
|
|
+ }else { //不存在
|
|
|
+ baseDao.execute("delete from SNBINDSET where ss_mothercode=?",ss_mothercode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ApiResponse.successRsp("0",requestId,"操作成功");
|
|
|
+ }*/
|
|
|
|
|
|
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
|
+ public void savelog(String actiontype, String json, String accesskey, String requestId){
|
|
|
+ int id = baseDao.getSeqId("EISAPILOG_SEQ");
|
|
|
+ baseDao.execute("insert into EISAPILOG(EL_ID,EL_ACTIONTYPE,EL_INDATE,EL_EMCODE) values(?,?,sysdate,?)",id,actiontype,accesskey);
|
|
|
+ baseDao.saveClob("EISAPILOG", "EL_DATA", json,"EL_ID=" +id);
|
|
|
}
|
|
|
+
|
|
|
private String checkAccessKey(String accessKey,String requestId){
|
|
|
Object accessSecret_O = baseDao.getFieldDataByCondition("APIEMPLOYEE", "AE_SECRET", "AE_KEY='"+accessKey+"'");
|
|
|
Object AE_MASTER = baseDao.getFieldDataByCondition("APIEMPLOYEE", "AE_MASTER", "AE_KEY='"+accessKey+"'");
|
|
|
@@ -559,4 +648,5 @@ public class MESDataServiceImpl implements MESDataService {
|
|
|
return AE_MASTER.toString();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|