若依框架
package com.ruoyi.fileop.controller;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.fileop.domain.Antivacuum;
import com.ruoyi.fileop.domain.Vacuum;
import com.ruoyi.fileop.service.DataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping("/dataComparison")
public class DataComparisonController extends BaseController {
@Autowired
private DataService dataService;
/**
* 真空包装比对接口
*
* @return
*/
@PostMapping("/vacuumShipDataComparison")
public AjaxResult vacuumShipDataComparison(@RequestBody Vacuum vacuum) {
System.out.println("vacuum = " + vacuum);
List<String []> objects1 = dataService.readFile1();
String [] date1 = objects1.get(0);
String p1 = date1[3];
Integer p2 = Integer.valueOf(date1[13]);
String p3 = date1[3];
Integer p4 = Integer.valueOf(date1[13]);
if(vacuum.getInship().equals(p1)
&&vacuum.getInshipQTY().equals(p2)
&&vacuum.getOutship().equals(p3)
&&vacuum.getOutshipQTY().equals(p4)
){
return AjaxResult.success("true");
}else{
return AjaxResult.success("false");
}
}
@PostMapping("/vacuumReturnDataComparison")
public AjaxResult vacuumReturnDataComparison(@RequestBody Vacuum vacuum) {
System.out.println("vacuum = " + vacuum);
List<String []> objects1 = dataService.readFile2();
String [] date2 = objects1.get(1);
String [] date1 = objects1.get(0);
String p1 = date1[3];
Integer p2 = Integer.valueOf(date1[13]);
String p3 = date1[3];
Integer p4 = Integer.valueOf(date1[13]);
String p5 = vacuum.getInreturn().substring(0,7);
Integer p6 = Integer.valueOf(date2[13]);
String p7 = vacuum.getOutreturn().substring(0,7);
Integer p8 = Integer.valueOf(date2[13]);
if(
vacuum.getInship().equals(p1)
&&vacuum.getInshipQTY().equals(p2)
&&vacuum.getOutship().equals(p3)
&&vacuum.getOutshipQTY().equals(p4)&&p5.equals(p7)
&&vacuum.getInreturnQTY().equals(p6)
&&vacuum.getOutreturnQTY().equals(p8)
){
return AjaxResult.success("true");
}else{
return AjaxResult.success("false");
}
}
/**
* 非真空包装比对结果
*
* @param antivacuum
* @return
*/
@PostMapping("/antivacuumShipDataComparison")
public AjaxResult antivacuumShipDataComparison(@RequestBody Antivacuum antivacuum) {
System.out.println("antivacuum = " + antivacuum);
Integer testdata=0;
List<String []> objects1 = dataService.readFile1();
String [] data1=objects1.get(0);
String p1 = data1[3];
Integer p2 = Integer.valueOf(data1[13]);
if (antivacuum.getOutship().equals(p1)
&& antivacuum.getOutshipQTY().equals(p2)
){
return AjaxResult.success("true");
}else{
return AjaxResult.success("false");
}
}
@PostMapping("/antivacuumReturnDataComparison")
public AjaxResult antivacuumReturnDataComparison(@RequestBody Antivacuum antivacuum) {
System.out.println("antivacuum = " + antivacuum);
Integer testdata=0;
List<String []> objects1 = dataService.readFile1();
String [] data2=objects1.get(1);
String p3 = data2[3];
Integer p4 = Integer.valueOf(data2[13]);
if (antivacuum.getOutreturn().equals(p3)
&& antivacuum.getOutreturnQTY().equals(p4)
){
return AjaxResult.success("true");
}else{
return AjaxResult.success("false");
}
}
}
运行结果及报错内容
我的解答思路和尝试过的方法
我想要达到的结果