yangys
2025-09-19 e70c88930c51c7afeb3cc2ac72fbe6fad86a942c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
package org.springblade.mdm.test;
 
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.mail.MessagingException;
import jakarta.xml.soap.SOAPException;
import jakarta.xml.ws.WebServiceContext;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.neethi.AssertionBuilderFactory;
import org.apache.ws.commons.schema.XmlSchemaSerializer;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.mdm.basesetting.machine.entity.Machine;
import org.springblade.mdm.commons.service.InternalEmailService;
import org.springblade.mdm.flow.entity.MesSync;
import org.springblade.mdm.flow.excution.events.CureFinishedEvent;
import org.springblade.mdm.flow.service.MesSyncService;
import org.springblade.mdm.flow.service.WIthdrawService;
import org.springblade.mdm.machinefile.entity.MachineFile;
import org.springblade.mdm.machinefile.service.MachineFileScanService;
import org.springblade.mdm.program.entity.NcNode;
import org.springblade.mdm.program.service.NcNodeHisService;
import org.springblade.mdm.program.service.NcNodeService;
import org.springblade.mdm.program.service.ProgramAnnotationService;
import org.springblade.mdm.task.InternalEmailNotifyTask;
import org.springblade.mdm.task.MachineFileScanTask;
import org.springblade.mdm.utils.FileContentUtil;
import org.springblade.system.feign.IDictBizClient;
import org.springblade.system.pojo.entity.DictBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.wsdl.WSDLException;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.util.List;
 
@Slf4j
@RestController
@RequestMapping("/test/")
@Tag(name = "测试", description = "测试")
public class MyTestController {
 
    @Autowired
    private NcNodeService service;
    @Autowired
    private MesSyncService mesSyncService;
    @Autowired
    private ProgramAnnotationService programAnnotationService;
    @Autowired
    private IDictBizClient bizDictClient;
    @Autowired
    private InternalEmailService mailService;
    @Autowired
    private MachineFileScanService machineFileScanService;
    @Autowired
    private WIthdrawService withdrawService;
    @Autowired
    private InternalEmailNotifyTask notifyTask;
 
    @Autowired
    private NcNodeHisService nodeHisService;
    /**
     * 新增
     */
    @GetMapping("/like")
    @Operation(summary = "like", description = "like")
    public R<Object> like() {
        try {
            List<NcNode> nodes = service.lambdaQuery()
                .likeRight(NcNode::getParentIds,"0,2,").list();
 
            return R.data(nodes);
        }catch (Exception e) {
            log.error("同步失败", e);;
            return R.fail(e.getMessage());
        }
 
    }
 
    /**
     * 新增
     */
    @GetMapping("/readline")
    @Operation(summary = "like", description = "like")
    public R<String> like(String file,int line) throws IOException {
        FileInputStream fis = new FileInputStream(file);
        return R.data(FileContentUtil.readLineAt(fis,line));
 
    }
 
    @GetMapping("/scandir")
    @Operation(summary = "test扫描", description = "test扫描")
    public R<Void> scan() throws IOException {
        Machine machine = new Machine();
        machine.setCode("M_01_FN");
        machine.setProgReceiveDir("d:/data/machine1/rec");
        machineFileScanService.scanDir(machine, MachineFile.DIR_TYPE_REC);
        return R.success();
    }
 
 
    @GetMapping("/dict-biz")
    @Operation(summary = "biz", description = "test扫描")
    public R<List<DictBiz>> giz(String code) throws IOException {
        log.info("mytset中的日志");
        return this.bizDictClient.getList    (code);
    }
 
    @GetMapping("/sendmail")
    @Operation(summary = "sendmail", description = "sendmail")
    public R<Void> sendmail(String from,String to,String subject,String content) throws IOException, MessagingException {
        this.mailService.send(from,to,null,null,subject,content,null);
        return R.success();
    }
 
    @GetMapping("/withdraw")
    public R<Void> withdraw(String id) throws IOException, MessagingException {
        withdrawService.withdraw(id);
        return R.success();
    }
 
    @GetMapping("/scanfile")
    public void scanFile(){
        machineFileScanService.scanMachineFile();
    }
 
    @GetMapping("/notify")
    public void emailNotify(){
        SOAPException s;
        notifyTask.execute();
    }
 
    @GetMapping("/movehis")
    public void moveHis(Date time){
        //format:?time=2025-09-16%2010:11:10
        nodeHisService.mergeNodeToHisGeTime(time);
    }
    @GetMapping("/mes-sync")
    public void mesSync(){
        mesSyncService.syncToMes();
    }
 
    @GetMapping("/publish-cure")
    public void publishCure(){
        CureFinishedEvent e = new CureFinishedEvent(this,"0000000173");
        SpringUtil.publishEvent(e);
    }
 
    @GetMapping("/call-mes")
    public void callMess(){
        JSONObject jsonObject = new JSONObject();
 
        JSONArray dataList = new JSONArray();
 
        JSONObject item = new JSONObject();
        item.put("operationId","id1");
        item.put("programNo","00001");
        item.put("curedTime", DateUtil.formatDateTime(new Date()));
 
        dataList.add(item);
 
        jsonObject.put("batchData", dataList);
 
        log.info("mestest data:{}",jsonObject);
 
        int code = mesSyncService.postData(jsonObject);
        log.info("mestest response:{}",code);
    }
}