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.
102 lines
3.7 KiB
Go
102 lines
3.7 KiB
Go
package cmd
|
|
|
|
import (
|
|
"cu-helper/cus-eng-con-sys/config"
|
|
"cu-helper/cus-eng-con-sys/cryptokit"
|
|
"cu-helper/cus-eng-con-sys/model"
|
|
"cu-helper/cus-eng-con-sys/service"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/go-resty/resty/v2"
|
|
"github.com/mizuki1412/go-core-kit/class/exception"
|
|
"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/configkit"
|
|
"github.com/mizuki1412/go-core-kit/service/logkit"
|
|
"github.com/spf13/cast"
|
|
"github.com/spf13/cobra"
|
|
"github.com/tidwall/gjson"
|
|
)
|
|
|
|
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()
|
|
pro := configkit.Get(config.EngProcess, "")
|
|
if pro == "" {
|
|
run()
|
|
}
|
|
client := resty.New().SetRetryCount(5).SetRetryWaitTime(15 * time.Second)
|
|
h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8")
|
|
header := h.GenReqParam()
|
|
f := model.NewTaskTodo(cast.ToString(pro))
|
|
form := f.GenReqParam()
|
|
resp, err := client.R().
|
|
SetHeaders(header).SetFormData(form).Post(config.UrlPrefix + "/zjgd/frm/workflow/taskToDo.action")
|
|
if err != nil {
|
|
panic(exception.New(err.Error()))
|
|
}
|
|
dataOri := strings.Trim(resp.String(), `"`)
|
|
data := cryptokit.Decrypt(dataOri)
|
|
_ = filekit.WriteFile("kr.json", []byte(data))
|
|
},
|
|
}
|
|
|
|
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")
|
|
cmd.Flags().String(config.EngProcess, "", "Specify the process")
|
|
}
|