|
@@ -9,12 +9,16 @@ import common.annotation.API;
|
|
|
import common.annotation.CACHEING;
|
|
|
import common.annotation.CACHEING_CLEAN;
|
|
|
import common.data.*;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
import restcontroller.R;
|
|
|
-
|
|
|
+import restcontroller.webmanage.sale.aftersalesbom.aftersalesbom;
|
|
|
+import restcontroller.webmanage.sale.aftersalesbom.aftersalesbom_items;
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collections;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@API(title = "bom结构")
|
|
|
public class bom extends Controller {
|
|
@@ -220,6 +224,92 @@ public class bom extends Controller {
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @API(title = "bom导入", apiversion = R.ID2025091009392103.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiClass = {bom.class})
|
|
|
+ public String importBoms() throws YosException {
|
|
|
+ ExcelFactory e;
|
|
|
+ try {
|
|
|
+
|
|
|
+ // 华为云
|
|
|
+ //e = getPostExcelFactory(content.getLong("attachmentid"));
|
|
|
+ // 本地
|
|
|
+ e = getPostExcelFactory();
|
|
|
+
|
|
|
+ ArrayList<String> keys = new ArrayList<>();
|
|
|
+ keys.add("bomname");
|
|
|
+ keys.add("module");
|
|
|
+ keys.add("component");
|
|
|
+ keys.add("accessorie");
|
|
|
+
|
|
|
+ Rows bomrows = dbConnect.runSqlQuery("select * from plm_bom ");
|
|
|
+ RowsMap bomrowsMap =bomrows.toRowsMap("bomname");
|
|
|
+ Rows rows = e.getSheetRows(0, keys, 3);
|
|
|
+ RowsMap bomnamerowsMap = rows.toRowsMap("bomname");
|
|
|
+ for (Map.Entry<String, Rows> entry : bomnamerowsMap.entrySet()) {
|
|
|
+ String key = entry.getKey();
|
|
|
+ long plm_bomid1=0;
|
|
|
+ if(!bomrowsMap.containsKey(key)){
|
|
|
+ plm_bomid1=inserbom(0,key,"1");
|
|
|
+ }else{
|
|
|
+ plm_bomid1=bomrowsMap.get(key).get(0).getLong("plm_bomid");
|
|
|
+ }
|
|
|
+ Rows modulerows = entry.getValue();
|
|
|
+ RowsMap modulerowsMap =modulerows.toRowsMap("module");
|
|
|
+ for (Map.Entry<String, Rows> entry1 : modulerowsMap.entrySet()) {
|
|
|
+ String key1 = entry1.getKey();
|
|
|
+ Long plm_bomid2=inserbom(plm_bomid1,key1,"1");
|
|
|
+ Rows componentrows = entry1.getValue();
|
|
|
+ RowsMap componentrowsMap =componentrows.toRowsMap("component");
|
|
|
+ for (Map.Entry<String, Rows> entry2 : componentrowsMap.entrySet()) {
|
|
|
+ String key2 = entry2.getKey();
|
|
|
+ long plm_bomid3=inserbom(plm_bomid2,key2,"1");
|
|
|
+ Rows accessorierows = entry2.getValue();
|
|
|
+ RowsMap accessorierowsMap =accessorierows.toRowsMap("accessorie");
|
|
|
+ for (Map.Entry<String, Rows> entry3 : accessorierowsMap.entrySet()) {
|
|
|
+ String key3 = entry3.getKey();
|
|
|
+ if(!StringUtils.isBlank(key3)){
|
|
|
+ inserbom(plm_bomid3,key3,"1");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ } catch (Exception e1) {
|
|
|
+ e1.printStackTrace();
|
|
|
+ return getErrReturnObject().setErrMsg(e1.getMessage()).toString();
|
|
|
+ }
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public long inserbom(long parentid,String bomname,String num) throws YosException {
|
|
|
+ long plm_bomid = 0;
|
|
|
+ ArrayList<String> sqllist = new ArrayList<>();
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "plm_bom");
|
|
|
+ plm_bomid = createTableID("plm_bom");
|
|
|
+ insertSQL.setUniqueid(plm_bomid);
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setValue("bomname", bomname);
|
|
|
+ insertSQL.setValue("parentid", parentid);
|
|
|
+ insertSQL.setValue("bomfullname",
|
|
|
+ getUppebomfullname(bomname, parentid, plm_bomid));
|
|
|
+ insertSQL.setValue("num", num);
|
|
|
+ insertSQL.setValue("isdeep", 1);
|
|
|
+ insertSQL.setValue("level", 1);
|
|
|
+ if (parentid > 0) {
|
|
|
+ sqllist = getbomlevel(1, parentid, plm_bomid, sqllist);
|
|
|
+ sqllist.add("update plm_bom set isdeep=0 where plm_bomid=" + parentid);
|
|
|
+ }
|
|
|
+ insertSQL.setValue("createby", username);
|
|
|
+ insertSQL.setDateValue("createdate");
|
|
|
+ sqllist.add(insertSQL.getSQL());
|
|
|
+ dbConnect.runSqlUpdate(sqllist);
|
|
|
+ return plm_bomid;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 递归查询下级产品类别
|
|
|
*
|