|
@@ -1,71 +1,74 @@
|
|
|
package com.sckj.device.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.github.yulichang.query.MPJQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.sckj.common.core.PageResult;
|
|
|
+import com.sckj.common.util.StringUtils;
|
|
|
import com.sckj.common.validate.commons.PageValidate;
|
|
|
+import com.sckj.device.entity.TDeviceFactory;
|
|
|
+import com.sckj.device.mapper.TDeviceFactoryMapper;
|
|
|
import com.sckj.device.service.ITDeviceFactoryService;
|
|
|
import com.sckj.device.validate.TDeviceFactoryCreateValidate;
|
|
|
-import com.sckj.device.validate.TDeviceFactoryUpdateValidate;
|
|
|
import com.sckj.device.validate.TDeviceFactorySearchValidate;
|
|
|
-import com.sckj.device.vo.TDeviceFactoryListedVo;
|
|
|
+import com.sckj.device.validate.TDeviceFactoryUpdateValidate;
|
|
|
import com.sckj.device.vo.TDeviceFactoryDetailVo;
|
|
|
-import com.sckj.common.config.GlobalConfig;
|
|
|
-import com.sckj.common.core.PageResult;
|
|
|
-import com.sckj.device.entity.TDeviceFactory;
|
|
|
-import com.sckj.device.mapper.TDeviceFactoryMapper;
|
|
|
-import com.sckj.common.util.ListUtils;
|
|
|
-import com.sckj.common.util.TimeUtils;
|
|
|
-import com.sckj.common.util.UrlUtils;
|
|
|
+import com.sckj.device.vo.TDeviceFactoryListedVo;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.*;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.LinkedList;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 设备厂家实现类
|
|
|
+ *
|
|
|
* @author zhanghao
|
|
|
*/
|
|
|
@Service
|
|
|
public class TDeviceFactoryServiceImpl implements ITDeviceFactoryService {
|
|
|
-
|
|
|
+
|
|
|
@Resource
|
|
|
TDeviceFactoryMapper tDeviceFactoryMapper;
|
|
|
|
|
|
/**
|
|
|
* 设备厂家列表
|
|
|
*
|
|
|
- * @author zhanghao
|
|
|
- * @param pageValidate 分页参数
|
|
|
+ * @param pageValidate 分页参数
|
|
|
* @param searchValidate 搜索参数
|
|
|
* @return PageResult<TDeviceFactoryListedVo>
|
|
|
+ * @author zhanghao
|
|
|
*/
|
|
|
@Override
|
|
|
public PageResult<TDeviceFactoryListedVo> list(PageValidate pageValidate, TDeviceFactorySearchValidate searchValidate) {
|
|
|
- Integer page = pageValidate.getPageNo();
|
|
|
+ Integer page = pageValidate.getPageNo();
|
|
|
Integer limit = pageValidate.getPageSize();
|
|
|
|
|
|
QueryWrapper<TDeviceFactory> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.orderByDesc("id");
|
|
|
|
|
|
+// if (StringUtils.isNotEmpty(searchValidate.getCreateTimeStart()) && StringUtils.isNotEmpty(searchValidate.getCreateTimeEnd())) {
|
|
|
+// queryWrapper.ge("create_time", searchValidate.getCreateTimeStart())
|
|
|
+// .le("create_time", searchValidate.getCreateTimeEnd());
|
|
|
+// }
|
|
|
+
|
|
|
tDeviceFactoryMapper.setSearch(queryWrapper, searchValidate, new String[]{
|
|
|
- "datetime:createTimeStart-createTimeEnd@create_time:str",
|
|
|
- "like:factoryName@factory_name:str",
|
|
|
- "=:factoryPhone@factory_phone:str",
|
|
|
- "=:factoryAddress@factory_address:str",
|
|
|
+ "like:factoryName@factory_name:str",
|
|
|
+ "=:factoryPhone@factory_phone:str",
|
|
|
+ "=:factoryAddress@factory_address:str",
|
|
|
});
|
|
|
|
|
|
IPage<TDeviceFactory> iPage = tDeviceFactoryMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
|
|
|
|
|
List<TDeviceFactoryListedVo> list = new LinkedList<>();
|
|
|
- for(TDeviceFactory item : iPage.getRecords()) {
|
|
|
+ for (TDeviceFactory item : iPage.getRecords()) {
|
|
|
TDeviceFactoryListedVo vo = new TDeviceFactoryListedVo();
|
|
|
BeanUtils.copyProperties(item, vo);
|
|
|
- vo.setCreateTime(TimeUtils.timestampToDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(item.getCreateTime())));
|
|
|
+ vo.setCreateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(item.getCreateTime()));
|
|
|
list.add(vo);
|
|
|
}
|
|
|
|
|
@@ -75,16 +78,16 @@ public class TDeviceFactoryServiceImpl implements ITDeviceFactoryService {
|
|
|
/**
|
|
|
* 设备厂家详情
|
|
|
*
|
|
|
- * @author zhanghao
|
|
|
* @param id 主键参数
|
|
|
* @return TDeviceFactory
|
|
|
+ * @author zhanghao
|
|
|
*/
|
|
|
@Override
|
|
|
public TDeviceFactoryDetailVo detail(Integer id) {
|
|
|
TDeviceFactory model = tDeviceFactoryMapper.selectOne(
|
|
|
new QueryWrapper<TDeviceFactory>()
|
|
|
- .eq("id", id)
|
|
|
- .last("limit 1"));
|
|
|
+ .eq("id", id)
|
|
|
+ .last("limit 1"));
|
|
|
|
|
|
Assert.notNull(model, "数据不存在");
|
|
|
|
|
@@ -97,8 +100,8 @@ public class TDeviceFactoryServiceImpl implements ITDeviceFactoryService {
|
|
|
/**
|
|
|
* 设备厂家新增
|
|
|
*
|
|
|
- * @author zhanghao
|
|
|
* @param createValidate 参数
|
|
|
+ * @author zhanghao
|
|
|
*/
|
|
|
@Override
|
|
|
public void add(TDeviceFactoryCreateValidate createValidate) {
|
|
@@ -111,22 +114,25 @@ public class TDeviceFactoryServiceImpl implements ITDeviceFactoryService {
|
|
|
model.setFactoryPhone(createValidate.getFactoryPhone());
|
|
|
model.setFactoryAddress(createValidate.getFactoryAddress());
|
|
|
model.setFactoryAddressDetail(createValidate.getFactoryAddressDetail());
|
|
|
- model.setQcPath(createValidate.getQcPath());
|
|
|
+ for (int i = 0; i < createValidate.getQcPathList().length; i++) {
|
|
|
+ createValidate.getQcPathList()[i] = createValidate.getQcPathList()[i].substring(35);
|
|
|
+ }
|
|
|
+ model.setQcPath(String.join(",", createValidate.getQcPathList()));
|
|
|
tDeviceFactoryMapper.insert(model);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设备厂家编辑
|
|
|
*
|
|
|
- * @author zhanghao
|
|
|
* @param updateValidate 参数
|
|
|
+ * @author zhanghao
|
|
|
*/
|
|
|
@Override
|
|
|
public void edit(TDeviceFactoryUpdateValidate updateValidate) {
|
|
|
TDeviceFactory model = tDeviceFactoryMapper.selectOne(
|
|
|
new QueryWrapper<TDeviceFactory>()
|
|
|
- .eq("id", updateValidate.getId())
|
|
|
- .last("limit 1"));
|
|
|
+ .eq("id", updateValidate.getId())
|
|
|
+ .last("limit 1"));
|
|
|
|
|
|
Assert.notNull(model, "数据不存在!");
|
|
|
|
|
@@ -136,22 +142,25 @@ public class TDeviceFactoryServiceImpl implements ITDeviceFactoryService {
|
|
|
model.setFactoryPhone(updateValidate.getFactoryPhone());
|
|
|
model.setFactoryAddress(updateValidate.getFactoryAddress());
|
|
|
model.setFactoryAddressDetail(updateValidate.getFactoryAddressDetail());
|
|
|
- model.setQcPath(updateValidate.getQcPath());
|
|
|
+ for (int i = 0; i < updateValidate.getQcPathList().length; i++) {
|
|
|
+ updateValidate.getQcPathList()[i] = updateValidate.getQcPathList()[i].substring(35);
|
|
|
+ }
|
|
|
+ model.setQcPath(String.join(",", updateValidate.getQcPathList()));
|
|
|
tDeviceFactoryMapper.updateById(model);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设备厂家删除
|
|
|
*
|
|
|
- * @author zhanghao
|
|
|
* @param id 主键ID
|
|
|
+ * @author zhanghao
|
|
|
*/
|
|
|
@Override
|
|
|
public void del(Integer id) {
|
|
|
TDeviceFactory model = tDeviceFactoryMapper.selectOne(
|
|
|
new QueryWrapper<TDeviceFactory>()
|
|
|
- .eq("id", id)
|
|
|
- .last("limit 1"));
|
|
|
+ .eq("id", id)
|
|
|
+ .last("limit 1"));
|
|
|
|
|
|
Assert.notNull(model, "数据不存在!");
|
|
|
|