作者 yangfu

Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creat…

…ion-manufacture into dev
@@ -328,9 +328,9 @@ func (srv *PullDataK3CloudService) PullPrdMo(timeFilter time.Time) error { @@ -328,9 +328,9 @@ func (srv *PullDataK3CloudService) PullPrdMo(timeFilter time.Time) error {
328 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 328 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
329 } 329 }
330 fieldKeys := []string{ 330 fieldKeys := []string{
331 - "FID", "FBillNo", "FWorkShopID", "FWorkShopID.FName", "FMaterialId", "FMaterialId.FName",  
332 - "FMaterialId.FNumber", "FPlanStartDate", "FPlanFinishDate", "FDate", "FQty",  
333 - "FCreateDate", "FModifyDate", "FPrdOrgId", "FPrdOrgId.FName", 331 + "FRowId", "FBillNo", "FWorkShopID", "FWorkShopID.FName", "FMaterialId", "FMaterialId.FName",
  332 + "FMaterialId.FNumber", "FMaterialId.FSpecification", "FPlanStartDate", "FPlanFinishDate", "FDate", "FQty",
  333 + "FCreateDate", "FModifyDate", "FPrdOrgId", "FPrdOrgId.FName", "FUnitId", "FUnitId.FName", "FDescription",
334 } 334 }
335 var ( 335 var (
336 startRow int 336 startRow int
@@ -368,21 +368,18 @@ func (srv *PullDataK3CloudService) PullPrdMo(timeFilter time.Time) error { @@ -368,21 +368,18 @@ func (srv *PullDataK3CloudService) PullPrdMo(timeFilter time.Time) error {
368 ) 368 )
369 nowTime := time.Now() 369 nowTime := time.Now()
370 for _, item := range allResult { 370 for _, item := range allResult {
371 - id, err := strconv.Atoi(item["FID"])  
372 - if err != nil {  
373 - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
374 - }  
375 - workShopID, _ := strconv.Atoi(item["WorkShopID"])  
376 - materialId, _ := strconv.Atoi(item["MaterialId"])  
377 - qty, _ := strconv.ParseFloat(item["Qty"], 64) 371 + workShopID, _ := strconv.Atoi(item["FWorkShopID"])
  372 + materialId, _ := strconv.Atoi(item["FMaterialId"])
  373 + qty, _ := strconv.ParseFloat(item["FQty"], 64)
378 fPrdOrgId, _ := strconv.Atoi(item["FPrdOrgId"]) 374 fPrdOrgId, _ := strconv.Atoi(item["FPrdOrgId"])
379 planStartDate, _ := time.Parse("2006-01-02T15:04:05", item["FPlanStartDate"]) 375 planStartDate, _ := time.Parse("2006-01-02T15:04:05", item["FPlanStartDate"])
380 planFinishDate, _ := time.Parse("2006-01-02T15:04:05", item["FPlanFinishDate"]) 376 planFinishDate, _ := time.Parse("2006-01-02T15:04:05", item["FPlanFinishDate"])
381 fDate, _ := time.Parse("2006-01-02T15:04:05", item["FDate"]) 377 fDate, _ := time.Parse("2006-01-02T15:04:05", item["FDate"])
382 fCreateDate, _ := time.Parse("2006-01-02T15:04:05.999", item["FCreateDate"]) 378 fCreateDate, _ := time.Parse("2006-01-02T15:04:05.999", item["FCreateDate"])
383 fModifyDate, _ := time.Parse("2006-01-02T15:04:05.999", item["FModifyDate"]) 379 fModifyDate, _ := time.Parse("2006-01-02T15:04:05.999", item["FModifyDate"])
  380 + fUnitId, _ := strconv.Atoi(item["FUnitId"])
384 prdMoTemp = models.PrdMoK3cloud{ 381 prdMoTemp = models.PrdMoK3cloud{
385 - Id: id, 382 + RowId: item["FRowId"],
386 WorkShopID: workShopID, 383 WorkShopID: workShopID,
387 MaterialId: materialId, 384 MaterialId: materialId,
388 Qty: qty, 385 Qty: qty,
@@ -398,6 +395,10 @@ func (srv *PullDataK3CloudService) PullPrdMo(timeFilter time.Time) error { @@ -398,6 +395,10 @@ func (srv *PullDataK3CloudService) PullPrdMo(timeFilter time.Time) error {
398 DataVersion: nowTime.Unix(), 395 DataVersion: nowTime.Unix(),
399 PrdOrgId: fPrdOrgId, 396 PrdOrgId: fPrdOrgId,
400 PrdOrgName: item["FPrdOrgId.FName"], 397 PrdOrgName: item["FPrdOrgId.FName"],
  398 + Specification: item["FMaterialId.FSpecification"],
  399 + UnitName: item["FUnitId.FName"],
  400 + UnitId: fUnitId,
  401 + Description: item["FDescription"],
401 } 402 }
402 prdMoModels = append(prdMoModels, prdMoTemp) 403 prdMoModels = append(prdMoModels, prdMoTemp)
403 } 404 }
@@ -30,8 +30,8 @@ func (d *PrdMoK3cloudDao) SyncDataPrdMoK3cloud(data []models.PrdMoK3cloud) error @@ -30,8 +30,8 @@ func (d *PrdMoK3cloudDao) SyncDataPrdMoK3cloud(data []models.PrdMoK3cloud) error
30 sqlValues := []string{} 30 sqlValues := []string{}
31 var strTemp []string 31 var strTemp []string
32 for i := range data { 32 for i := range data {
33 - strTemp = make([]string, 0, 5)  
34 - strTemp = append(strTemp, strconv.Itoa(data[i].Id)) 33 + strTemp = make([]string, 0, 15)
  34 + strTemp = append(strTemp, `'`+data[i].RowId+`'`)
35 strTemp = append(strTemp, `'`+data[i].BillNo+`'`) 35 strTemp = append(strTemp, `'`+data[i].BillNo+`'`)
36 strTemp = append(strTemp, strconv.Itoa(data[i].WorkShopID)) 36 strTemp = append(strTemp, strconv.Itoa(data[i].WorkShopID))
37 strTemp = append(strTemp, `'`+data[i].WorkShopName+`'`) 37 strTemp = append(strTemp, `'`+data[i].WorkShopName+`'`)
@@ -47,6 +47,12 @@ func (d *PrdMoK3cloudDao) SyncDataPrdMoK3cloud(data []models.PrdMoK3cloud) error @@ -47,6 +47,12 @@ func (d *PrdMoK3cloudDao) SyncDataPrdMoK3cloud(data []models.PrdMoK3cloud) error
47 strTemp = append(strTemp, strconv.Itoa(int(data[i].DataVersion))) 47 strTemp = append(strTemp, strconv.Itoa(int(data[i].DataVersion)))
48 strTemp = append(strTemp, strconv.Itoa(data[i].PrdOrgId)) 48 strTemp = append(strTemp, strconv.Itoa(data[i].PrdOrgId))
49 strTemp = append(strTemp, `'`+data[i].PrdOrgName+`'`) 49 strTemp = append(strTemp, `'`+data[i].PrdOrgName+`'`)
  50 + strTemp = append(strTemp, `'`+data[i].UnitName+`'`)
  51 + strTemp = append(strTemp, strconv.Itoa(data[i].UnitId))
  52 + strTemp = append(strTemp, `'`+data[i].Specification+`'`)
  53 + strTemp = append(strTemp, `'`+data[i].Description+`'`)
  54 + //关联的计划管理表id ,使用 product_plan 产品表的自增序列表
  55 + strTemp = append(strTemp, "nextval('manufacture.product_plan_product_plan_id_seq'::regclass)")
50 sqlValues = append(sqlValues, "("+strings.Join(strTemp, ",")+")") 56 sqlValues = append(sqlValues, "("+strings.Join(strTemp, ",")+")")
51 } 57 }
52 var valueTemp []string 58 var valueTemp []string
@@ -57,28 +63,32 @@ func (d *PrdMoK3cloudDao) SyncDataPrdMoK3cloud(data []models.PrdMoK3cloud) error @@ -57,28 +63,32 @@ func (d *PrdMoK3cloudDao) SyncDataPrdMoK3cloud(data []models.PrdMoK3cloud) error
57 valueTemp = sqlValues[i:] 63 valueTemp = sqlValues[i:]
58 } 64 }
59 sql := `INSERT INTO "manufacture"."prd_mo_k3cloud" ( 65 sql := `INSERT INTO "manufacture"."prd_mo_k3cloud" (
60 - "id","bill_no","work_shop_id","work_shop_name", 66 + "row_id","bill_no","work_shop_id","work_shop_name",
61 "material_id","material_name","material_number", 67 "material_id","material_name","material_number",
62 "plan_start_date","plan_finish_date","f_date", 68 "plan_start_date","plan_finish_date","f_date",
63 "qty","create_date","modify_date","data_version", 69 "qty","create_date","modify_date","data_version",
64 - "prd_org_id","prd_org_name") 70 + "prd_org_id","prd_org_name","unit_name","unit_id",
  71 + "specification","description","join_product_plan_id")
65 VALUES ` + 72 VALUES ` +
66 strings.Join(valueTemp, ",") + 73 strings.Join(valueTemp, ",") +
67 - ` ON conflict ( "id" ) DO 74 + ` ON conflict ( "row_id" ) DO
68 UPDATE 75 UPDATE
69 SET ( 76 SET (
70 "bill_no","work_shop_id","work_shop_name", 77 "bill_no","work_shop_id","work_shop_name",
71 "material_id","material_name","material_number", 78 "material_id","material_name","material_number",
72 "plan_start_date","plan_finish_date","f_date", 79 "plan_start_date","plan_finish_date","f_date",
73 "qty","create_date","modify_date","data_version", 80 "qty","create_date","modify_date","data_version",
74 - "prd_org_id","prd_org_name") = ( 81 + "prd_org_id","prd_org_name","unit_name","unit_id",
  82 + "specification","description") = (
75 EXCLUDED."bill_no",EXCLUDED."work_shop_id", 83 EXCLUDED."bill_no",EXCLUDED."work_shop_id",
76 EXCLUDED."work_shop_name",EXCLUDED."material_id", 84 EXCLUDED."work_shop_name",EXCLUDED."material_id",
77 EXCLUDED."material_name",EXCLUDED."material_number", 85 EXCLUDED."material_name",EXCLUDED."material_number",
78 EXCLUDED."plan_start_date",EXCLUDED."plan_finish_date", 86 EXCLUDED."plan_start_date",EXCLUDED."plan_finish_date",
79 EXCLUDED."f_date",EXCLUDED."qty",EXCLUDED."create_date", 87 EXCLUDED."f_date",EXCLUDED."qty",EXCLUDED."create_date",
80 EXCLUDED."modify_date",EXCLUDED."data_version", 88 EXCLUDED."modify_date",EXCLUDED."data_version",
81 - EXCLUDED."prd_org_id",EXCLUDED."prd_org_name" 89 + EXCLUDED."prd_org_id",EXCLUDED."prd_org_name",
  90 + EXCLUDED."unit_name",EXCLUDED."unit_id",
  91 + EXCLUDED."specification",EXCLUDED."description"
82 )` 92 )`
83 _, err := d.transactionContext.PgTx.Exec(sql) 93 _, err := d.transactionContext.PgTx.Exec(sql)
84 if err != nil { 94 if err != nil {
@@ -103,3 +113,8 @@ func (d *PrdMoK3cloudDao) GetLastVersion() (int64, error) { @@ -103,3 +113,8 @@ func (d *PrdMoK3cloudDao) GetLastVersion() (int64, error) {
103 } 113 }
104 return prdMoData[0].DataVersion, nil 114 return prdMoData[0].DataVersion, nil
105 } 115 }
  116 +
  117 +//SyncDataProductPlan 同步数据到
  118 +func (d *PrdMoK3cloudDao) SyncDataProductPlan() {
  119 +
  120 +}
@@ -9,7 +9,7 @@ type MaterialK3cloud struct { @@ -9,7 +9,7 @@ type MaterialK3cloud struct {
9 Name string `comment:"物料名称" pg:"name"` 9 Name string `comment:"物料名称" pg:"name"`
10 Number string `comment:"物料编码" pg:"number"` 10 Number string `comment:"物料编码" pg:"number"`
11 Specification string `comment:"规格型号" pg:"specification"` 11 Specification string `comment:"规格型号" pg:"specification"`
12 - ForbidStatus string `comment:"禁用状态,"A":否,"B":是" pg:"forbid_status"` 12 + ForbidStatus string `comment:"禁用状态,A:否,B:是" pg:"forbid_status"`
13 ErpClsId int `comment:"物料属性" pg:"erp_cls_id"` 13 ErpClsId int `comment:"物料属性" pg:"erp_cls_id"`
14 BaseUnitId int `comment:"基本单位" pg:"base_unit_id"` 14 BaseUnitId int `comment:"基本单位" pg:"base_unit_id"`
15 BaseUnitName string `comment:"基本单位名称" pg:"base_unit_name"` 15 BaseUnitName string `comment:"基本单位名称" pg:"base_unit_name"`
@@ -6,7 +6,7 @@ import "time" @@ -6,7 +6,7 @@ import "time"
6 //PrdMoK3cloud .. 6 //PrdMoK3cloud ..
7 type PrdMoK3cloud struct { 7 type PrdMoK3cloud struct {
8 tableName string `comment:"采集自金蝶k3cloud计划订单" pg:"manufacture.prd_mo_k3cloud,alias:prd_mo_k3cloud"` 8 tableName string `comment:"采集自金蝶k3cloud计划订单" pg:"manufacture.prd_mo_k3cloud,alias:prd_mo_k3cloud"`
9 - Id int `pg:",pk"` 9 + RowId string `pg:",pk"`
10 BillNo string `comment:"订单编号" pg:"bill_no"` 10 BillNo string `comment:"订单编号" pg:"bill_no"`
11 WorkShopID int `comment:"生产车间" pg:"work_shop_id"` 11 WorkShopID int `comment:"生产车间" pg:"work_shop_id"`
12 WorkShopName string `comment:"生产车间名称" pg:"work_shop_name"` 12 WorkShopName string `comment:"生产车间名称" pg:"work_shop_name"`
@@ -22,4 +22,9 @@ type PrdMoK3cloud struct { @@ -22,4 +22,9 @@ type PrdMoK3cloud struct {
22 DataVersion int64 `comment:"数据版本" pg:"data_version"` 22 DataVersion int64 `comment:"数据版本" pg:"data_version"`
23 PrdOrgId int `comment:"生产组织" pg:"prd_org_id"` 23 PrdOrgId int `comment:"生产组织" pg:"prd_org_id"`
24 PrdOrgName string `comment:"生产组织名称" pg:"prd_org_name"` 24 PrdOrgName string `comment:"生产组织名称" pg:"prd_org_name"`
  25 + UnitName string `comment:"单位名称" pg:"unit_name"`
  26 + UnitId int `comment:"单位id" pg:"unit_id"`
  27 + Specification string `comment:"规格型号" pg:"specification"`
  28 + Description string `comment:"备注" pg:"description"`
  29 + JoinProductPlanId int `comment:"计划管理表的id" pg:"join_product_plan_id"`
25 } 30 }
@@ -65,16 +65,17 @@ func TestExecuteBillQuery2(t *testing.T) { @@ -65,16 +65,17 @@ func TestExecuteBillQuery2(t *testing.T) {
65 return 65 return
66 } 66 }
67 fieldKeys := []string{ 67 fieldKeys := []string{
68 - "FID", "FBillNo", "FWorkShopID", "FWorkShopID.FName", "FMaterialId", "FMaterialId.FName",  
69 - "FMaterialId.FNumber", "FPlanStartDate", "FPlanFinishDate", "FDate", "FQty",  
70 - "FCreateDate", "FModifyDate", "FPrdOrgId", "FPrdOrgId.FName", 68 + "FBillNo", "FWorkShopID", "FWorkShopID.FName", "FMaterialId", "FMaterialId.FName",
  69 + "FMaterialId.FNumber", "FMaterialId.FSpecification", "FPlanStartDate", "FPlanFinishDate", "FDate", "FQty",
  70 + "FCreateDate", "FModifyDate", "FPrdOrgId", "FPrdOrgId.FName", "FRowId", "FUnitId", "FUnitId.FName", "FDescription",
71 } 71 }
72 result, err := client.ExecuteBillQuery(RequestExecuteBillQuery{ 72 result, err := client.ExecuteBillQuery(RequestExecuteBillQuery{
73 FormId: "PRD_MO", 73 FormId: "PRD_MO",
74 Data: ExecuteBillQueryData{ 74 Data: ExecuteBillQueryData{
75 FormId: "PRD_MO", 75 FormId: "PRD_MO",
76 FieldKeys: strings.Join(fieldKeys, ","), //查询的字段 76 FieldKeys: strings.Join(fieldKeys, ","), //查询的字段
77 - TopRowCount: 2, 77 + TopRowCount: 4,
  78 +
78 FilterString: "", 79 FilterString: "",
79 }, 80 },
80 }) 81 })