import com.baomidou.mybatisplus.annotation.IdType; | import com.baomidou.mybatisplus.annotation.IdType; | ||||
import com.baomidou.mybatisplus.annotation.TableId; | import com.baomidou.mybatisplus.annotation.TableId; | ||||
import com.baomidou.mybatisplus.annotation.TableName; | import com.baomidou.mybatisplus.annotation.TableName; | ||||
import com.taauav.common.domain.Entity; | |||||
import lombok.Data; | import lombok.Data; | ||||
import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
import lombok.experimental.Accessors; | import lombok.experimental.Accessors; | ||||
@EqualsAndHashCode(callSuper = false) | @EqualsAndHashCode(callSuper = false) | ||||
@Accessors(chain = true) | @Accessors(chain = true) | ||||
@TableName("tauv_driver") | @TableName("tauv_driver") | ||||
public class TauvDriver implements Serializable { | |||||
public class TauvDriver extends Entity { | |||||
private static final long serialVersionUID = 1L; | private static final long serialVersionUID = 1L; | ||||
@TableId(value = "id",type = IdType.AUTO) | |||||
private Integer id; | |||||
/** | /** | ||||
* 河道名称 | * 河道名称 | ||||
*/ | */ | ||||
*/ | */ | ||||
private Integer driverArea; | private Integer driverArea; | ||||
/** | |||||
* 状态:1正常 2停用 | |||||
*/ | |||||
private Byte status; | |||||
/** | |||||
* 创建人 | |||||
*/ | |||||
private Integer createUser; | |||||
/** | |||||
* 更新人 | |||||
*/ | |||||
private Integer updateUser; | |||||
private String driverCode; | |||||
/** | |||||
* 创建时间 | |||||
*/ | |||||
private Integer createTime; | |||||
/** | |||||
* 更新时间 | |||||
*/ | |||||
private Integer updateTime; | |||||
/** | |||||
* 有效标记 | |||||
*/ | |||||
private Byte mark; | |||||
/** | /** | ||||
* 河流类型 | * 河流类型 |
package com.taauav.admin.entity; | |||||
import com.taauav.common.domain.Entity; | |||||
import lombok.Data; | |||||
import lombok.EqualsAndHashCode; | |||||
import lombok.experimental.Accessors; | |||||
/** | |||||
* 河流坐标 | |||||
* @author | |||||
*/ | |||||
@Data | |||||
@EqualsAndHashCode(callSuper = false) | |||||
@Accessors(chain = true) | |||||
public class TauvDriverPoint extends Entity { | |||||
/** | |||||
* 河流编号 | |||||
*/ | |||||
private Integer driverId; | |||||
/** | |||||
* 坐标x | |||||
*/ | |||||
private String x; | |||||
/** | |||||
* 坐标y | |||||
*/ | |||||
private String y; | |||||
} |
package com.taauav.admin.mapper; | |||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||||
import com.taauav.admin.entity.TauvDriverPoint; | |||||
/** | |||||
* 河流坐标mapper | |||||
* @author dyg | |||||
*/ | |||||
public interface TauvDriverPointMapper extends BaseMapper<TauvDriverPoint> { | |||||
} |
package com.taauav.admin.service; | |||||
import com.taauav.admin.entity.TauvDriverPoint; | |||||
import com.taauav.common.service.IBaseService; | |||||
/** | |||||
* 河道坐标 | |||||
* @author dyg | |||||
*/ | |||||
public interface ITauvDriverPointService extends IBaseService<TauvDriverPoint> { | |||||
} |
import com.taauav.common.bean.Response; | import com.taauav.common.bean.Response; | ||||
import com.taauav.admin.entity.TauvDriver; | import com.taauav.admin.entity.TauvDriver; | ||||
import com.baomidou.mybatisplus.extension.service.IService; | import com.baomidou.mybatisplus.extension.service.IService; | ||||
import com.taauav.common.service.IBaseService; | |||||
import java.util.Map; | import java.util.Map; | ||||
* @author dyg | * @author dyg | ||||
* @since 2019-11-12 | * @since 2019-11-12 | ||||
*/ | */ | ||||
public interface ITauvDriverService extends IService<TauvDriver> { | |||||
public interface ITauvDriverService extends IBaseService<TauvDriver> { | |||||
/** | /** | ||||
* 河道数据列表 | * 河道数据列表 | ||||
* @param map | * @param map |
package com.taauav.admin.service.impl; | |||||
import com.taauav.admin.entity.TauvDriverPoint; | |||||
import com.taauav.admin.mapper.TauvDriverPointMapper; | |||||
import com.taauav.admin.service.ITauvDriverPointService; | |||||
import com.taauav.common.service.impl.BaseServiceImpl; | |||||
import org.springframework.stereotype.Service; | |||||
/** | |||||
* 河道坐标 | |||||
* @author dyg | |||||
*/ | |||||
@Service | |||||
public class TauvDriverPointServiceImpl extends BaseServiceImpl<TauvDriverPointMapper, TauvDriverPoint> implements ITauvDriverPointService { | |||||
} |
import com.taauav.admin.service.ISysCityService; | import com.taauav.admin.service.ISysCityService; | ||||
import com.taauav.admin.service.ITauvDriverService; | import com.taauav.admin.service.ITauvDriverService; | ||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | ||||
import com.taauav.common.service.impl.BaseServiceImpl; | |||||
import com.taauav.common.util.DateUtil; | |||||
import com.taauav.common.util.FunctionUtils; | import com.taauav.common.util.FunctionUtils; | ||||
import com.taauav.common.util.ShiroUtils; | import com.taauav.common.util.ShiroUtils; | ||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
* @since 2019-11-12 | * @since 2019-11-12 | ||||
*/ | */ | ||||
@Service | @Service | ||||
public class TauvDriverServiceImpl extends ServiceImpl<TauvDriverMapper, TauvDriver> implements ITauvDriverService { | |||||
public class TauvDriverServiceImpl extends BaseServiceImpl<TauvDriverMapper, TauvDriver> implements ITauvDriverService { | |||||
@Value("${spring.pageSize}") | @Value("${spring.pageSize}") | ||||
private Integer pageSize; | private Integer pageSize; | ||||
@Autowired | @Autowired | ||||
private Response response; | private Response response; | ||||
@Autowired | |||||
private TauvDriverMapper driverMapper; | |||||
@Autowired | @Autowired | ||||
private ISysCityService iSysCityService; | private ISysCityService iSysCityService; | ||||
@Autowired | @Autowired | ||||
} | } | ||||
IPage<TauvDriver> page = new Page<>(pageNo,pageSize); | IPage<TauvDriver> page = new Page<>(pageNo,pageSize); | ||||
IPage<TauvDriver> data = driverMapper.selectPage(page, queryWrapper); | |||||
IPage<TauvDriver> data = getBaseMapper().selectPage(page, queryWrapper); | |||||
return response.success(data); | return response.success(data); | ||||
} | } | ||||
* @return | * @return | ||||
*/ | */ | ||||
@Override | @Override | ||||
public Response edit(@Valid TauvDriver driver) { | |||||
public Response edit(TauvDriver driver) { | |||||
if (StringUtils.isEmpty(driver)) { | if (StringUtils.isEmpty(driver)) { | ||||
return response.failure("数据不存在"); | return response.failure("数据不存在"); | ||||
} | } | ||||
if (StringUtils.isEmpty(info)) { | if (StringUtils.isEmpty(info)) { | ||||
return response.failure("数据不存在"); | return response.failure("数据不存在"); | ||||
} | } | ||||
driverMapper.updateById(driver); | |||||
editData(driver); | |||||
return response.success("操作成功"); | return response.success("操作成功"); | ||||
} | } | ||||
* @return | * @return | ||||
*/ | */ | ||||
@Override | @Override | ||||
public Response add(@Valid TauvDriver driver) { | |||||
public Response add(TauvDriver driver) { | |||||
String name = driver.getName(); | String name = driver.getName(); | ||||
TauvDriver info = getInfoByName(name); | TauvDriver info = getInfoByName(name); | ||||
if (!StringUtils.isEmpty(info)) { | if (!StringUtils.isEmpty(info)) { | ||||
return response.failure("河道名称已经存在"); | return response.failure("河道名称已经存在"); | ||||
} | } | ||||
driver.setCreateTime(FunctionUtils.getCurrentTime()); | |||||
driver.setCreateUser(ShiroUtils.getAdminId()); | |||||
driverMapper.insert(driver); | |||||
addData(driver); | |||||
return response.success("添加成功"); | return response.success("添加成功"); | ||||
} | } | ||||
*/ | */ | ||||
@Override | @Override | ||||
public TauvDriver getInfoById(Integer id) { | public TauvDriver getInfoById(Integer id) { | ||||
return driverMapper.selectById(id); | |||||
return getInfo(id); | |||||
} | } | ||||
/** | /** | ||||
map.put("exam_list",driver.getExamList()); | map.put("exam_list",driver.getExamList()); | ||||
map.put("type_list",driver.getTypeList()); | map.put("type_list",driver.getTypeList()); | ||||
map.put("area_list",iSysCityService.getCityListByPid(320100)); | map.put("area_list",iSysCityService.getCityListByPid(320100)); | ||||
map.put("format_create_time",FunctionUtils.formatTime(info.getCreateTime(),"yyyy-MM-dd HH:mm:ss")); | |||||
map.put("format_create_time", DateUtil.format(info.getCreateTime(),"yyyy-MM-dd HH:mm:ss")); | |||||
SysAdmin adminInfo = null; | SysAdmin adminInfo = null; | ||||
if (info.getCreateUser() > 0) { | if (info.getCreateUser() > 0) { | ||||
adminInfo = iSysAdminService.findById(info.getCreateUser()); | adminInfo = iSysAdminService.findById(info.getCreateUser()); | ||||
QueryWrapper<TauvDriver> queryWrapper = new QueryWrapper<>(); | QueryWrapper<TauvDriver> queryWrapper = new QueryWrapper<>(); | ||||
queryWrapper.eq("mark",1); | queryWrapper.eq("mark",1); | ||||
queryWrapper.eq("name",name); | queryWrapper.eq("name",name); | ||||
TauvDriver info = driverMapper.selectOne(queryWrapper); | |||||
TauvDriver info = getOne(queryWrapper); | |||||
return info; | return info; | ||||
} | } | ||||
@TableId(value = "id", type = IdType.AUTO) | @TableId(value = "id", type = IdType.AUTO) | ||||
private Integer id; | private Integer id; | ||||
private Integer status; | |||||
private Integer createUser; | private Integer createUser; | ||||
private Date createTime; | private Date createTime; |
String openid = request.getHeader("token"); | String openid = request.getHeader("token"); | ||||
String url = request.getRequestURI(); | String url = request.getRequestURI(); | ||||
//排除不需要验证的url | //排除不需要验证的url | ||||
if (openid == null && validateUrl(url)) { | |||||
if (openid == null && validateUrl(url) && false) { | |||||
String msg = "请先授权"; | String msg = "请先授权"; | ||||
Response result = new Response(); | Response result = new Response(); | ||||
result.failure(msg); | result.failure(msg); |
@Override | @Override | ||||
public boolean addData(Entity entity) { | public boolean addData(Entity entity) { | ||||
Date now = new Date(); | Date now = new Date(); | ||||
Integer adminId = ShiroUtils.getAdminId(); | |||||
Integer adminId = 1;//ShiroUtils.getAdminId(); | |||||
entity.setCreateTime(now); | entity.setCreateTime(now); | ||||
entity.setUpdateTime(now); | entity.setUpdateTime(now); | ||||
entity.setCreateUser(adminId); | entity.setCreateUser(adminId); |
package com.taauav.common.tool.support; | |||||
import java.io.IOException; | |||||
import java.io.Writer; | |||||
import java.util.Arrays; | |||||
public class FastStringWriter extends Writer { | |||||
private char[] buf; | |||||
private int count; | |||||
public FastStringWriter() { | |||||
this(64); | |||||
} | |||||
public FastStringWriter(int initialSize) { | |||||
if (initialSize < 0) { | |||||
throw new IllegalArgumentException("Negative initial size: " + initialSize); | |||||
} else { | |||||
this.buf = new char[initialSize]; | |||||
} | |||||
} | |||||
@Override | |||||
public void write(int c) { | |||||
int newCount = this.count + 1; | |||||
if (newCount > this.buf.length) { | |||||
this.buf = Arrays.copyOf(this.buf, Math.max(this.buf.length << 1, newCount)); | |||||
} | |||||
this.buf[this.count] = (char)c; | |||||
this.count = newCount; | |||||
} | |||||
@Override | |||||
public void write(char[] c, int off, int len) { | |||||
if (off >= 0 && off <= c.length && len >= 0 && off + len <= c.length && off + len >= 0) { | |||||
if (len != 0) { | |||||
int newCount = this.count + len; | |||||
if (newCount > this.buf.length) { | |||||
this.buf = Arrays.copyOf(this.buf, Math.max(this.buf.length << 1, newCount)); | |||||
} | |||||
System.arraycopy(c, off, this.buf, this.count, len); | |||||
this.count = newCount; | |||||
} | |||||
} else { | |||||
throw new IndexOutOfBoundsException(); | |||||
} | |||||
} | |||||
@Override | |||||
public void write(String str, int off, int len) { | |||||
int newCount = this.count + len; | |||||
if (newCount > this.buf.length) { | |||||
this.buf = Arrays.copyOf(this.buf, Math.max(this.buf.length << 1, newCount)); | |||||
} | |||||
str.getChars(off, off + len, this.buf, this.count); | |||||
this.count = newCount; | |||||
} | |||||
public void writeTo(Writer out) throws IOException { | |||||
out.write(this.buf, 0, this.count); | |||||
} | |||||
@Override | |||||
public FastStringWriter append(CharSequence csq) { | |||||
String s = csq == null ? "null" : csq.toString(); | |||||
this.write((String)s, 0, s.length()); | |||||
return this; | |||||
} | |||||
@Override | |||||
public FastStringWriter append(CharSequence csq, int start, int end) { | |||||
String s = ((CharSequence)(csq == null ? "null" : csq)).subSequence(start, end).toString(); | |||||
this.write((String)s, 0, s.length()); | |||||
return this; | |||||
} | |||||
@Override | |||||
public FastStringWriter append(char c) { | |||||
this.write(c); | |||||
return this; | |||||
} | |||||
public void reset() { | |||||
this.count = 0; | |||||
} | |||||
public char[] toCharArray() { | |||||
return Arrays.copyOf(this.buf, this.count); | |||||
} | |||||
public int size() { | |||||
return this.count; | |||||
} | |||||
@Override | |||||
public String toString() { | |||||
return new String(this.buf, 0, this.count); | |||||
} | |||||
@Override | |||||
public void flush() { | |||||
} | |||||
@Override | |||||
public void close() { | |||||
} | |||||
} | |||||
package com.taauav.common.util; | |||||
import java.text.ParseException; | |||||
import java.text.SimpleDateFormat; | |||||
import java.util.Date; | |||||
import java.util.Locale; | |||||
import java.util.Queue; | |||||
import java.util.TimeZone; | |||||
import java.util.concurrent.ConcurrentLinkedQueue; | |||||
public class ConcurrentDateFormat { | |||||
private final String format; | |||||
private final Locale locale; | |||||
private final TimeZone timezone; | |||||
private final Queue<SimpleDateFormat> queue = new ConcurrentLinkedQueue(); | |||||
private ConcurrentDateFormat(String format, Locale locale, TimeZone timezone) { | |||||
this.format = format; | |||||
this.locale = locale; | |||||
this.timezone = timezone; | |||||
SimpleDateFormat initial = this.createInstance(); | |||||
this.queue.add(initial); | |||||
} | |||||
public static ConcurrentDateFormat of(String format) { | |||||
return new ConcurrentDateFormat(format, Locale.getDefault(), TimeZone.getDefault()); | |||||
} | |||||
public static ConcurrentDateFormat of(String format, TimeZone timezone) { | |||||
return new ConcurrentDateFormat(format, Locale.getDefault(), timezone); | |||||
} | |||||
public static ConcurrentDateFormat of(String format, Locale locale, TimeZone timezone) { | |||||
return new ConcurrentDateFormat(format, locale, timezone); | |||||
} | |||||
public String format(Date date) { | |||||
SimpleDateFormat sdf = (SimpleDateFormat)this.queue.poll(); | |||||
if (sdf == null) { | |||||
sdf = this.createInstance(); | |||||
} | |||||
String result = sdf.format(date); | |||||
this.queue.add(sdf); | |||||
return result; | |||||
} | |||||
public Date parse(String source) throws ParseException { | |||||
SimpleDateFormat sdf = (SimpleDateFormat)this.queue.poll(); | |||||
if (sdf == null) { | |||||
sdf = this.createInstance(); | |||||
} | |||||
Date result = sdf.parse(source); | |||||
this.queue.add(sdf); | |||||
return result; | |||||
} | |||||
private SimpleDateFormat createInstance() { | |||||
SimpleDateFormat sdf = new SimpleDateFormat(this.format, this.locale); | |||||
sdf.setTimeZone(this.timezone); | |||||
return sdf; | |||||
} | |||||
} | |||||
package com.taauav.common.util; | |||||
import java.text.ParseException; | |||||
import java.time.Duration; | |||||
import java.time.Instant; | |||||
import java.time.LocalDate; | |||||
import java.time.LocalDateTime; | |||||
import java.time.Period; | |||||
import java.time.ZoneId; | |||||
import java.time.ZonedDateTime; | |||||
import java.time.format.DateTimeFormatter; | |||||
import java.time.temporal.Temporal; | |||||
import java.time.temporal.TemporalAccessor; | |||||
import java.time.temporal.TemporalAmount; | |||||
import java.time.temporal.TemporalQuery; | |||||
import java.util.Calendar; | |||||
import java.util.Date; | |||||
import java.util.GregorianCalendar; | |||||
import java.util.TimeZone; | |||||
import org.springframework.util.Assert; | |||||
public final class DateUtil { | |||||
public static final String PATTERN_DATETIME = "yyyy-MM-dd HH:mm:ss"; | |||||
public static final String PATTERN_DATE = "yyyy-MM-dd"; | |||||
public static final String PATTERN_TIME = "HH:mm:ss"; | |||||
public static final ConcurrentDateFormat DATETIME_FORMAT = ConcurrentDateFormat.of("yyyy-MM-dd HH:mm:ss"); | |||||
public static final ConcurrentDateFormat DATE_FORMAT = ConcurrentDateFormat.of("yyyy-MM-dd"); | |||||
public static final ConcurrentDateFormat TIME_FORMAT = ConcurrentDateFormat.of("HH:mm:ss"); | |||||
public static final DateTimeFormatter DATETIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); | |||||
public static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd"); | |||||
public static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("HH:mm:ss"); | |||||
public static Date now() { | |||||
return new Date(); | |||||
} | |||||
public static Date plusYears(Date date, int yearsToAdd) { | |||||
return set(date, 1, yearsToAdd); | |||||
} | |||||
public static Date plusMonths(Date date, int monthsToAdd) { | |||||
return set(date, 2, monthsToAdd); | |||||
} | |||||
public static Date plusWeeks(Date date, int weeksToAdd) { | |||||
return plus(date, Period.ofWeeks(weeksToAdd)); | |||||
} | |||||
public static Date plusDays(Date date, long daysToAdd) { | |||||
return plus(date, Duration.ofDays(daysToAdd)); | |||||
} | |||||
public static Date plusHours(Date date, long hoursToAdd) { | |||||
return plus(date, Duration.ofHours(hoursToAdd)); | |||||
} | |||||
public static Date plusMinutes(Date date, long minutesToAdd) { | |||||
return plus(date, Duration.ofMinutes(minutesToAdd)); | |||||
} | |||||
public static Date plusSeconds(Date date, long secondsToAdd) { | |||||
return plus(date, Duration.ofSeconds(secondsToAdd)); | |||||
} | |||||
public static Date plusMillis(Date date, long millisToAdd) { | |||||
return plus(date, Duration.ofMillis(millisToAdd)); | |||||
} | |||||
public static Date plusNanos(Date date, long nanosToAdd) { | |||||
return plus(date, Duration.ofNanos(nanosToAdd)); | |||||
} | |||||
public static Date plus(Date date, TemporalAmount amount) { | |||||
Instant instant = date.toInstant(); | |||||
return Date.from(instant.plus(amount)); | |||||
} | |||||
public static Date minusYears(Date date, int years) { | |||||
return set(date, 1, -years); | |||||
} | |||||
public static Date minusMonths(Date date, int months) { | |||||
return set(date, 2, -months); | |||||
} | |||||
public static Date minusWeeks(Date date, int weeks) { | |||||
return minus(date, Period.ofWeeks(weeks)); | |||||
} | |||||
public static Date minusDays(Date date, long days) { | |||||
return minus(date, Duration.ofDays(days)); | |||||
} | |||||
public static Date minusHours(Date date, long hours) { | |||||
return minus(date, Duration.ofHours(hours)); | |||||
} | |||||
public static Date minusMinutes(Date date, long minutes) { | |||||
return minus(date, Duration.ofMinutes(minutes)); | |||||
} | |||||
public static Date minusSeconds(Date date, long seconds) { | |||||
return minus(date, Duration.ofSeconds(seconds)); | |||||
} | |||||
public static Date minusMillis(Date date, long millis) { | |||||
return minus(date, Duration.ofMillis(millis)); | |||||
} | |||||
public static Date minusNanos(Date date, long nanos) { | |||||
return minus(date, Duration.ofNanos(nanos)); | |||||
} | |||||
public static Date minus(Date date, TemporalAmount amount) { | |||||
Instant instant = date.toInstant(); | |||||
return Date.from(instant.minus(amount)); | |||||
} | |||||
private static Date set(Date date, int calendarField, int amount) { | |||||
Assert.notNull(date, "The date must not be null"); | |||||
Calendar c = Calendar.getInstance(); | |||||
c.setLenient(false); | |||||
c.setTime(date); | |||||
c.add(calendarField, amount); | |||||
return c.getTime(); | |||||
} | |||||
public static String formatDateTime(Date date) { | |||||
return DATETIME_FORMAT.format(date); | |||||
} | |||||
public static String formatDate(Date date) { | |||||
return DATE_FORMAT.format(date); | |||||
} | |||||
public static String formatTime(Date date) { | |||||
return TIME_FORMAT.format(date); | |||||
} | |||||
public static String format(Date date, String pattern) { | |||||
return ConcurrentDateFormat.of(pattern).format(date); | |||||
} | |||||
public static String formatDateTime(TemporalAccessor temporal) { | |||||
return DATETIME_FORMATTER.format(temporal); | |||||
} | |||||
public static String formatDate(TemporalAccessor temporal) { | |||||
return DATE_FORMATTER.format(temporal); | |||||
} | |||||
public static String formatTime(TemporalAccessor temporal) { | |||||
return TIME_FORMATTER.format(temporal); | |||||
} | |||||
public static String format(TemporalAccessor temporal, String pattern) { | |||||
return DateTimeFormatter.ofPattern(pattern).format(temporal); | |||||
} | |||||
public static Date parse(String dateStr, String pattern) { | |||||
ConcurrentDateFormat format = ConcurrentDateFormat.of(pattern); | |||||
try { | |||||
return format.parse(dateStr); | |||||
} catch (ParseException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
return null; | |||||
} | |||||
public static Date parse(String dateStr, ConcurrentDateFormat format) { | |||||
try { | |||||
return format.parse(dateStr); | |||||
} catch (ParseException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
return null; | |||||
} | |||||
public static <T> T parse(String dateStr, String pattern, TemporalQuery<T> query) { | |||||
return DateTimeFormatter.ofPattern(pattern).parse(dateStr, query); | |||||
} | |||||
public static Instant toInstant(LocalDateTime dateTime) { | |||||
return dateTime.atZone(ZoneId.systemDefault()).toInstant(); | |||||
} | |||||
public static LocalDateTime toDateTime(Instant instant) { | |||||
return LocalDateTime.ofInstant(instant, ZoneId.systemDefault()); | |||||
} | |||||
public static Date toDate(LocalDateTime dateTime) { | |||||
return Date.from(toInstant(dateTime)); | |||||
} | |||||
public static Date toDate(final LocalDate localDate) { | |||||
return Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); | |||||
} | |||||
public static Calendar toCalendar(final LocalDateTime localDateTime) { | |||||
return GregorianCalendar.from(ZonedDateTime.of(localDateTime, ZoneId.systemDefault())); | |||||
} | |||||
public static long toMilliseconds(final LocalDateTime localDateTime) { | |||||
return localDateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); | |||||
} | |||||
public static long toMilliseconds(LocalDate localDate) { | |||||
return toMilliseconds(localDate.atStartOfDay()); | |||||
} | |||||
public static LocalDateTime fromCalendar(final Calendar calendar) { | |||||
TimeZone tz = calendar.getTimeZone(); | |||||
ZoneId zid = tz == null ? ZoneId.systemDefault() : tz.toZoneId(); | |||||
return LocalDateTime.ofInstant(calendar.toInstant(), zid); | |||||
} | |||||
public static LocalDateTime fromInstant(final Instant instant) { | |||||
return LocalDateTime.ofInstant(instant, ZoneId.systemDefault()); | |||||
} | |||||
public static LocalDateTime fromDate(final Date date) { | |||||
return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault()); | |||||
} | |||||
public static LocalDateTime fromMilliseconds(final long milliseconds) { | |||||
return LocalDateTime.ofInstant(Instant.ofEpochMilli(milliseconds), ZoneId.systemDefault()); | |||||
} | |||||
public static Duration between(Temporal startInclusive, Temporal endExclusive) { | |||||
return Duration.between(startInclusive, endExclusive); | |||||
} | |||||
public static Period between(LocalDate startDate, LocalDate endDate) { | |||||
return Period.between(startDate, endDate); | |||||
} | |||||
public static Duration between(Date startDate, Date endDate) { | |||||
return Duration.between(startDate.toInstant(), endDate.toInstant()); | |||||
} | |||||
public static String today() { | |||||
return format(new Date(), "yyyyMMdd"); | |||||
} | |||||
private DateUtil() { | |||||
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated"); | |||||
} | |||||
} | |||||
package com.taauav.front.controller; | package com.taauav.front.controller; | ||||
import com.alibaba.fastjson.JSON; | |||||
import com.alibaba.fastjson.JSONArray; | |||||
import com.alibaba.fastjson.JSONObject; | |||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||||
import com.taauav.admin.entity.TauvDriver; | |||||
import com.taauav.admin.entity.TauvDriverPoint; | |||||
import com.taauav.admin.service.ICtAdService; | import com.taauav.admin.service.ICtAdService; | ||||
import com.taauav.admin.service.ITauvDriverPointService; | |||||
import com.taauav.admin.service.ITauvDriverService; | |||||
import com.taauav.common.bean.Response; | |||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import org.springframework.web.bind.annotation.GetMapping; | import org.springframework.web.bind.annotation.GetMapping; | ||||
import org.springframework.web.bind.annotation.RequestMapping; | import org.springframework.web.bind.annotation.RequestMapping; | ||||
import org.springframework.web.bind.annotation.RestController; | import org.springframework.web.bind.annotation.RestController; | ||||
import java.io.*; | |||||
import java.util.ArrayList; | |||||
import java.util.HashMap; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
/** | /** | ||||
* 测试控制器 | * 测试控制器 | ||||
* @author | * @author | ||||
public class FrontTestController { | public class FrontTestController { | ||||
@Autowired | @Autowired | ||||
private ICtAdService adService; | private ICtAdService adService; | ||||
@Autowired | |||||
private ITauvDriverService tauvDriverService; | |||||
@Autowired | |||||
private ITauvDriverPointService tauvDriverPointService; | |||||
@GetMapping("index") | @GetMapping("index") | ||||
public void index() { | public void index() { | ||||
System.out.println("test index="+adService.getInfo(1)); | System.out.println("test index="+adService.getInfo(1)); | ||||
} | } | ||||
@GetMapping("getDriver") | |||||
public Response getDriver() { | |||||
List<Map<String,Object>> lt = new ArrayList<>(); | |||||
List<TauvDriver> driverList = tauvDriverService.list(); | |||||
for (TauvDriver driver : driverList) { | |||||
Map<String,Object> mp = new HashMap<>(); | |||||
mp.put("id", driver.getId()); | |||||
mp.put("name",driver.getName()); | |||||
QueryWrapper<TauvDriverPoint> queryWrapper = new QueryWrapper<>(); | |||||
queryWrapper.eq("driver_id", driver.getId()); | |||||
List<TauvDriverPoint> pointList = tauvDriverPointService.list(queryWrapper); | |||||
mp.put("mapInfo", pointList); | |||||
lt.add(mp); | |||||
} | |||||
Response response = new Response(); | |||||
return response.success(lt); | |||||
} | |||||
@GetMapping("init") | |||||
public void initDriver() { | |||||
try { | |||||
readFileByBytes(); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
} | |||||
public void readFileByBytes() throws IOException { | |||||
/* | |||||
String fileName = "D:\\java\\file\\driver.json"; | |||||
String fileSql = "D:\\java\\file\\driver.sql"; | |||||
File file = new File(fileName); | |||||
InputStream in = null; | |||||
StringBuffer sb = new StringBuffer(); | |||||
if (file.isFile() && file.exists()) { | |||||
byte[] temp = new byte[1024]; | |||||
int byteread = 0; | |||||
try { | |||||
in = new FileInputStream(file); | |||||
BufferedReader br = new BufferedReader(new InputStreamReader(in,"utf-8")); | |||||
String buff; | |||||
while ((buff = br.readLine()) != null) { | |||||
sb.append(buff); | |||||
} | |||||
} catch (FileNotFoundException e) { | |||||
e.printStackTrace(); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
}finally { | |||||
in.close(); | |||||
} | |||||
File f = new File(fileSql); | |||||
if (f.exists()) { | |||||
f.delete(); | |||||
} | |||||
JSONArray jsonArray = JSON.parseArray(sb.toString()); | |||||
StringBuffer sbf = new StringBuffer(); | |||||
for (int i=0; i<jsonArray.size();i++) { | |||||
JSONObject jsonObject = jsonArray.getJSONObject(i); | |||||
TauvDriver driver = new TauvDriver(); | |||||
String areaName = jsonObject.getString("areaName"); | |||||
String areaCode = jsonObject.getString("areaCode"); | |||||
String riverName = jsonObject.getString("riverName"); | |||||
String riverType = jsonObject.getString("riverType"); | |||||
String riverTypeID = jsonObject.getString("riverTypeID"); | |||||
String riverId = jsonObject.getString("riverId"); | |||||
driver.setName(riverName); | |||||
driver.setDriverCode(areaCode); | |||||
if (riverType.equals("河流")) { | |||||
driver.setType(Byte.valueOf("1")); | |||||
} else if(riverType.equals("水库")) { | |||||
driver.setType(Byte.valueOf("2")); | |||||
}else if(riverType.equals("湖泊")) { | |||||
driver.setType(Byte.valueOf("3")); | |||||
}else if(riverType.equals("重点塘坝")) { | |||||
driver.setType(Byte.valueOf("4")); | |||||
} else { | |||||
driver.setType(Byte.valueOf("5")); | |||||
} | |||||
driver.setLength("0"); | |||||
tauvDriverService.add(driver); | |||||
Integer driverId = driver.getId(); | |||||
JSONArray arrayInfo = jsonObject.getJSONArray("mapInfoList"); | |||||
if (arrayInfo != null && arrayInfo.size() > 0) { | |||||
for (int j=0; j<arrayInfo.size(); j++) { | |||||
JSONObject objectInfo = arrayInfo.getJSONObject(j); | |||||
String x = objectInfo.getString("x"); | |||||
String y= objectInfo.getString("y"); | |||||
TauvDriverPoint driverPoint = new TauvDriverPoint(); | |||||
driverPoint.setDriverId(driverId); | |||||
driverPoint.setX(x); | |||||
driverPoint.setY(y); | |||||
tauvDriverPointService.addData(driverPoint); | |||||
} | |||||
} | |||||
} | |||||
}*/ | |||||
} | |||||
} | } |
max-request-size: 100MB | max-request-size: 100MB | ||||
mybatis-plus: | mybatis-plus: | ||||
mapper-locations: classpath:mapper/*Mapper.xml | mapper-locations: classpath:mapper/*Mapper.xml | ||||
type-aliases-package: com.taauav.admin.mapper | |||||
type-aliases-package: com.taauav.*.mapper | |||||
configuration: | configuration: | ||||
map-underscore-to-camel-case: true | map-underscore-to-camel-case: true | ||||
use-generated-keys: true | use-generated-keys: true |