forked from I3-YF/i3plus-mes-yfai
脚本本地备份
parent
a244b350f2
commit
3f466e59b6
@ -0,0 +1,58 @@
|
||||
import cn.estsh.i3plus.ext.mes.pojo.util.OverwriteStringJoin
|
||||
import cn.estsh.i3plus.platform.common.tool.TimeTool
|
||||
import cn.estsh.i3plus.platform.plugin.datasource.DynamicDataSourceProxy
|
||||
import cn.estsh.i3plus.pojo.mes.dbinterface.MesInterfaceDataMapper
|
||||
import lombok.Getter
|
||||
import lombok.Setter
|
||||
import org.apache.commons.collections.CollectionUtils
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.util.StringUtils
|
||||
|
||||
import javax.annotation.Resource
|
||||
import java.sql.Connection
|
||||
|
||||
/**
|
||||
* @Description : PiscesToMesBom
|
||||
* @Reference :
|
||||
* @Author : junsheng.li
|
||||
* @CreateDate 2024/11/24 12:40
|
||||
* @Modify:
|
||||
* */
|
||||
class PiscesToMesBom {
|
||||
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(PiscesToMesBom.class)
|
||||
|
||||
@Resource(name = "mesDataSource")
|
||||
private DynamicDataSourceProxy mesDataSource;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private Connection mesConn;
|
||||
|
||||
|
||||
def filterData(MesInterfaceDataMapper mapper, List<Map<String, Object>> srcData) throws Exception {
|
||||
if (srcData == null || srcData.size() == 0) {
|
||||
return srcData
|
||||
}
|
||||
String organizeCode = mapper.getOrganizeCode();
|
||||
List<String> partNoList = new ArrayList<>();
|
||||
for (Map<String, Object> rowMap : srcData) {
|
||||
//零件号
|
||||
if (!StringUtils.isEmpty(rowMap.get("PART_NO"))) {
|
||||
partNoList.add(String.valueOf(rowMap.get("PART_NO")))
|
||||
}
|
||||
}
|
||||
updateMesBomDelete(organizeCode, partNoList);
|
||||
return srcData;
|
||||
}
|
||||
|
||||
private void updateMesBomDelete(String organizeCode, List<String> partNoList) {
|
||||
if (StringUtils.isEmpty(organizeCode) || CollectionUtils.isEmpty(partNoList)) return;
|
||||
List<String> updateList = new ArrayList<>();
|
||||
updateList.add("update mes_bom set system_sync_date_time='" + TimeTool.getNowTime(true) + "',system_sync_status = 2,is_deleted=1 where organize_code = '" + organizeCode + "' and part_no in (" + OverwriteStringJoin.join(",", partNoList) + ") ;")
|
||||
this.mesConn = mesDataSource.getWriteConnectionWithoutPool();
|
||||
mesDataSource.executeAsBatch(updateList, mesConn)
|
||||
mesDataSource.closeConnectionWithoutPoll(this.mesConn)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue