xiangpei
2024-08-29 3e9a6da99aae968123ee7bca352fc08becd7f1f2
ycl-server/src/main/java/com/ycl/platform/controller/YwPointController.java
@@ -5,11 +5,15 @@
import com.ycl.system.domain.group.Add;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotBlank;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import lombok.RequiredArgsConstructor;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import org.springframework.validation.annotation.Validated;
@@ -114,10 +118,26 @@
        ywPointService.export(query, response);
    }
    @PostMapping("/import/{unitId}")
    @PostMapping("/import")
    @ApiOperation(value = "导入数据", notes = "导入数据")
    public Result importData(MultipartFile file, @PathVariable("unitId") Integer unitId, Date startTime, Date endTime, Boolean provinceTag, Boolean importantTag, Boolean importantCommandImageTag) throws IOException {
        return ywPointService.importData(file, unitId, startTime, endTime, provinceTag, importantTag, importantCommandImageTag);
    public Result importData(MultipartFile file,
                             Integer unitId,
                             String startTime,
                             String endTime) throws IOException, ParseException {
        Date start = null;
        Date end = null;
        if (-1 == unitId) {
            unitId = null;
        }
        if (StringUtils.hasText(startTime)) {
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
            start = format.parse(startTime);
        }
        if (StringUtils.hasText(startTime)) {
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
            end = format.parse(endTime);
        }
        return ywPointService.importData(file, unitId, start, end);
    }
}