You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.8 KiB
Go
79 lines
2.8 KiB
Go
package cmd
|
|
|
|
import (
|
|
"cu-helper/cus-eng-con-sys/config"
|
|
"cu-helper/cus-eng-con-sys/model"
|
|
"cu-helper/cus-eng-con-sys/service"
|
|
"github.com/go-resty/resty/v2"
|
|
"github.com/mizuki1412/go-core-kit/init/initkit"
|
|
"github.com/mizuki1412/go-core-kit/library/commonkit"
|
|
"github.com/mizuki1412/go-core-kit/library/filekit"
|
|
"github.com/mizuki1412/go-core-kit/service/logkit"
|
|
"github.com/spf13/cobra"
|
|
"github.com/tidwall/gjson"
|
|
"time"
|
|
)
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(engSysCmd)
|
|
defFlagsEng(engSysCmd)
|
|
}
|
|
|
|
var engSysCmd = &cobra.Command{
|
|
Use: "eng",
|
|
Short: "Batch processing operations of the cus-eng-con-sys",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
initkit.BindFlags(cmd)
|
|
config.Init()
|
|
run()
|
|
},
|
|
}
|
|
|
|
func run() {
|
|
j, _ := filekit.ReadString("kr.json")
|
|
data := gjson.Get(j, "data").Array()
|
|
client := resty.New().SetRetryCount(5).SetRetryWaitTime(15 * time.Second)
|
|
ctx := new(model.Ctx)
|
|
ctx.RestyClient = client
|
|
for _, v := range data {
|
|
ctx.Data = &v
|
|
logkit.Info("***现在开始处理***:" + v.Get("tasktitle").String())
|
|
_ = commonkit.RecoverFuncWrapper(func() {
|
|
var handlers = map[config.Status]func(){
|
|
//小区新建、扩容
|
|
{Step: "设计委托", Process: config.ProcessHouse}: func() { service.ReqPdmEntrust(ctx) },
|
|
{Step: "方案确认", Process: config.ProcessHouse}: func() { service.ReqDesignScheme(ctx) },
|
|
{Step: "工程开工", Process: config.ProcessHouse}: func() { service.ReqStartAct(ctx) },
|
|
//{Step: "完工确认", Process: config.ProcessHouse}: func() {},
|
|
{Step: "验收确认", Process: config.ProcessHouse}: func() { service.ReqAccConfirm(ctx) },
|
|
{Step: "验收交付申请", Process: config.ProcessYSJF}: func() { service.ReqAccDelivery(ctx) },
|
|
//零星
|
|
//{Step: "项目方案制作", Process: config.ProcessLX}: func() {},
|
|
{Step: "方案确认", Process: config.ProcessLX}: func() { service.ReqDesignScheme(ctx) },
|
|
//{Step: "完工确认", Process: config.ProcessLX}: func() {},
|
|
//{Step: "验收确认", Process: config.ProcessLX}: func() {},
|
|
//{Step: "验收交付申请", Process: config.ProcessYSJF}: func() {},
|
|
//楼宇
|
|
//{Step: "设计委托", Process: config.ProcessBuilding}: func() {},
|
|
//{Step: "方案确认", Process: config.ProcessBuilding}: func() {},
|
|
//{Step: "完工确认", Process: config.ProcessBuilding}: func() {},
|
|
//{Step: "验收确认", Process: config.ProcessBuilding}: func() {},
|
|
//{Step: "验收交付申请", Process: config.ProcessYSJF}: func() {},
|
|
//todo 工程评价
|
|
}
|
|
status := config.Status{
|
|
Step: v.Get("name").String(),
|
|
Process: v.Get("processDefinitionKey").String(),
|
|
}
|
|
if h, ok := handlers[status]; ok {
|
|
h()
|
|
}
|
|
})
|
|
time.Sleep(1 * time.Second)
|
|
}
|
|
}
|
|
|
|
func defFlagsEng(cmd *cobra.Command) {
|
|
cmd.Flags().String(config.EngSysSid, "", "Specify the sid")
|
|
}
|