no message
parent
d5a326394d
commit
07ec36733f
|
|
@ -43,7 +43,9 @@ import io.swagger.annotations.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
|
@ -102,10 +104,11 @@ public class ExcelConfigController {
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
@PostMapping(value = "/import")
|
@PostMapping(value = "/import")
|
||||||
@ApiOperation("导入点位")
|
|
||||||
@AnonymousAccess
|
@AnonymousAccess
|
||||||
@Transactional
|
@Transactional
|
||||||
public ResponseEntity<Object> importPoint(@RequestParam("file") MultipartFile multipartFile,@RequestParam("tableName") String tableNames) {
|
public ResponseEntity<Object> importPoint(@RequestParam("file") MultipartFile multipartFile,@RequestParam("tableName") String tableNames) {
|
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
String startData=dateFormat.format(new Date());
|
||||||
/*通过权限匹配对应的数据库表*/
|
/*通过权限匹配对应的数据库表*/
|
||||||
String tableName = getTableName(tableNames);
|
String tableName = getTableName(tableNames);
|
||||||
FileUtil.checkSize(properties.getMaxSize(), multipartFile.getSize());
|
FileUtil.checkSize(properties.getMaxSize(), multipartFile.getSize());
|
||||||
|
|
@ -133,73 +136,78 @@ public class ExcelConfigController {
|
||||||
Map<String, Object> readMap=readAll.get(i);
|
Map<String, Object> readMap=readAll.get(i);
|
||||||
for (int j = 0; j < excelConfigList.size(); j++) {
|
for (int j = 0; j < excelConfigList.size(); j++) {
|
||||||
ExcelConfig EI=excelConfigList.get(j);
|
ExcelConfig EI=excelConfigList.get(j);
|
||||||
/* 唯一判定*/
|
try {
|
||||||
if (EI.getOnlyFlag()==true){
|
/* 唯一判定*/
|
||||||
if (readMap.get(EI.getExcelColumnName())==null){
|
if (EI.getOnlyFlag()==true){
|
||||||
throw new BadRequestException(EI.getExcelColumnName()+"本字段不能为空");
|
if (readMap.get(EI.getExcelColumnName())==null){
|
||||||
}else {
|
throw new BadRequestException(EI.getExcelColumnName()+"本字段不能为空");
|
||||||
Object value=readMap.get(EI.getExcelColumnName());
|
|
||||||
|
|
||||||
String hql ="select * from "+tableName+" where "+EI.getTableColumnName()+"="+ EI.getFormat(value,EI.getTableColumnType());
|
|
||||||
// System.out.println(hql);
|
|
||||||
Query query = entityManager.createNativeQuery(hql);
|
|
||||||
List<T> qL= query.getResultList();
|
|
||||||
if (qL.size()<1){
|
|
||||||
//新增
|
|
||||||
}else {
|
}else {
|
||||||
//修改
|
Object value=readMap.get(EI.getExcelColumnName());
|
||||||
editEI=EI;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (readMap.get(EI.getExcelColumnName())!=null||(EI.getDefaultValue()!=null&&EI.getDefaultValue().length()>0)){
|
String hql ="select * from "+tableName+" where "+EI.getTableColumnName()+"="+ EI.getFormat(value,EI.getTableColumnType());
|
||||||
/* 获取导入值*/
|
// System.out.println(hql);
|
||||||
Object value;
|
|
||||||
if (readMap.get(EI.getExcelColumnName())!=null){
|
|
||||||
value = readMap.get(EI.getExcelColumnName());
|
|
||||||
}else {
|
|
||||||
value=EI.getDefaultValue();
|
|
||||||
}
|
|
||||||
/*添加到sql字段集*/
|
|
||||||
if (EI.getGlbType()==1){
|
|
||||||
/* 外键关联*/
|
|
||||||
ExcelConfigKey excelConfigKey=EI.getEcKey();
|
|
||||||
if (excelConfigKey!=null){
|
|
||||||
/*获取外键id*/
|
|
||||||
String hql ="select "+excelConfigKey.getKeyName()+" from "+excelConfigKey.getTableName()+" where "+excelConfigKey.getTableColumnName()+"="+ EI.getFormat(value,excelConfigKey.getTableColumnType());
|
|
||||||
// System.out.println(hql);
|
|
||||||
Query query = entityManager.createNativeQuery(hql);
|
Query query = entityManager.createNativeQuery(hql);
|
||||||
List<T> qL= query.getResultList();
|
List<T> qL= query.getResultList();
|
||||||
if (qL.size()>0){
|
if (qL.size()<1){
|
||||||
value=qL.get(0);
|
//新增
|
||||||
}else {
|
}else {
|
||||||
value=null;
|
//修改
|
||||||
|
editEI=EI;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else
|
}
|
||||||
if (EI.getGlbType()==2){
|
|
||||||
/*关联字典*/
|
if (readMap.get(EI.getExcelColumnName())!=null||(EI.getDefaultValue()!=null&&EI.getDefaultValue().length()>0)){
|
||||||
String hql =" select dd.`value` from sys_dict_detail dd "
|
/* 获取导入值*/
|
||||||
+" left join sys_dict d on dd.dict_id=d.dict_id "
|
Object value;
|
||||||
+" where d.`name`='"+EI.getDictName()+"' and dd.label='"+value+"' ";
|
/*写入 默认值*/
|
||||||
Query query = entityManager.createNativeQuery(hql);
|
if (readMap.get(EI.getExcelColumnName())!=null){
|
||||||
List<T> qL= query.getResultList();
|
value = readMap.get(EI.getExcelColumnName());
|
||||||
if (qL.size()<1){
|
}else {
|
||||||
throw new BadRequestException("未找到字典:"+EI.getExcelColumnName()+","+value);
|
value=EI.getDefaultValue();
|
||||||
|
}
|
||||||
|
/*添加到sql字段集*/
|
||||||
|
if (EI.getGlbType()==1){
|
||||||
|
/* 外键关联*/
|
||||||
|
ExcelConfigKey excelConfigKey=EI.getEcKey();
|
||||||
|
if (excelConfigKey!=null){
|
||||||
|
/*获取外键id*/
|
||||||
|
String hql ="select "+excelConfigKey.getKeyName()+" from "+excelConfigKey.getTableName()+" where "+excelConfigKey.getTableColumnName()+"="+ EI.getFormat(value,excelConfigKey.getTableColumnType());
|
||||||
|
// System.out.println(hql);
|
||||||
|
Query query = entityManager.createNativeQuery(hql);
|
||||||
|
List<T> qL= query.getResultList();
|
||||||
|
if (qL.size()>0){
|
||||||
|
value=qL.get(0);
|
||||||
|
}else {
|
||||||
|
value=null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else
|
||||||
|
if (EI.getGlbType()==2){
|
||||||
|
/*关联字典*/
|
||||||
|
String hql =" select dd.`value` from sys_dict_detail dd "
|
||||||
|
+" left join sys_dict d on dd.dict_id=d.dict_id "
|
||||||
|
+" where d.`name`='"+EI.getDictName()+"' and dd.label='"+value+"' ";
|
||||||
|
Query query = entityManager.createNativeQuery(hql);
|
||||||
|
List<T> qL= query.getResultList();
|
||||||
|
if (qL.size()<1){
|
||||||
|
throw new BadRequestException("未找到字典:"+EI.getExcelColumnName()+","+value);
|
||||||
|
}
|
||||||
|
value=qL.get(0);
|
||||||
|
}
|
||||||
|
if (columns.toString().length() < 1) {
|
||||||
|
columns.append(EI.getTableColumnName());
|
||||||
|
} else {
|
||||||
|
columns.append("," + EI.getTableColumnName());
|
||||||
|
}
|
||||||
|
if (values.toString().length() < 1) {
|
||||||
|
values.append(EI.getFormat(value,EI.getTableColumnType()));
|
||||||
|
} else {
|
||||||
|
values.append("," + EI.getFormat(value,EI.getTableColumnType()));
|
||||||
}
|
}
|
||||||
value=qL.get(0);
|
|
||||||
}
|
|
||||||
if (columns.toString().length() < 1) {
|
|
||||||
columns.append(EI.getTableColumnName());
|
|
||||||
} else {
|
|
||||||
columns.append("," + EI.getTableColumnName());
|
|
||||||
}
|
|
||||||
if (values.toString().length() < 1) {
|
|
||||||
values.append(EI.getFormat(value,EI.getTableColumnType()));
|
|
||||||
} else {
|
|
||||||
values.append("," + EI.getFormat(value,EI.getTableColumnType()));
|
|
||||||
}
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new BadRequestException("第"+i+"行,"+EI.getExcelColumnName()+"列"+","+e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String sql;
|
String sql;
|
||||||
|
|
@ -222,6 +230,11 @@ public class ExcelConfigController {
|
||||||
entityManager.createNativeQuery(sql)
|
entityManager.createNativeQuery(sql)
|
||||||
.executeUpdate();
|
.executeUpdate();
|
||||||
}
|
}
|
||||||
|
String endDate=dateFormat.format(new Date());
|
||||||
|
|
||||||
|
System.out.println("导入,开始时间:"+ dateFormat.format(new Date())+"结束时间:"+ dateFormat.format(new Date()));
|
||||||
|
/*entityManager.createNativeQuery(sqlBf.toString())
|
||||||
|
.executeUpdate();*/
|
||||||
/*System.out.println(sqlBf);
|
/*System.out.println(sqlBf);
|
||||||
*//* 执行sql语句*//*
|
*//* 执行sql语句*//*
|
||||||
entityManager.createNativeQuery(sqlBf.toString())
|
entityManager.createNativeQuery(sqlBf.toString())
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,126 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Zheng Jie
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.youchain.basicdata.domain;
|
||||||
|
|
||||||
|
import com.youchain.base.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import cn.hutool.core.bean.copier.CopyOptions;
|
||||||
|
import javax.persistence.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @website https://eladmin.vip
|
||||||
|
* @description /
|
||||||
|
* @author houjianlan
|
||||||
|
* @date 2024-09-26
|
||||||
|
**/
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
@Table(name="base_work_point")
|
||||||
|
public class WorkPoint extends BaseEntity implements Serializable {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(name = "`id`")
|
||||||
|
@ApiModelProperty(value = "主键")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Column(name = "`code`",unique = true,nullable = false)
|
||||||
|
@NotBlank
|
||||||
|
@ApiModelProperty(value = "编码")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
@Column(name = "`name`")
|
||||||
|
@ApiModelProperty(value = "名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@OneToOne
|
||||||
|
@JoinColumn(name = "area_id")
|
||||||
|
@ApiModelProperty(value = "库区ID")
|
||||||
|
private Area area;
|
||||||
|
|
||||||
|
@Column(name = "`up_number`",nullable = false)
|
||||||
|
@NotNull
|
||||||
|
@ApiModelProperty(value = "上料接驳口数")
|
||||||
|
private Integer upNumber;
|
||||||
|
|
||||||
|
@OneToOne
|
||||||
|
@JoinColumn(name = "up_point_id",nullable = false)
|
||||||
|
@ApiModelProperty(value = "上料料接驳口")
|
||||||
|
@NotNull
|
||||||
|
private Point upPoint;
|
||||||
|
|
||||||
|
@Column(name = "`down_number`")
|
||||||
|
@ApiModelProperty(value = "下料接驳口数")
|
||||||
|
private Integer downNumber;
|
||||||
|
@OneToOne
|
||||||
|
@JoinColumn(name = "down_point_id",nullable = false)
|
||||||
|
@ApiModelProperty(value = "下料接驳口")
|
||||||
|
@NotNull
|
||||||
|
private Point downPoint;
|
||||||
|
|
||||||
|
@Column(name = "`agv_number`")
|
||||||
|
@ApiModelProperty(value = "接驳口车辆数")
|
||||||
|
private Integer agvNumber;
|
||||||
|
|
||||||
|
@Column(name = "`max_number`")
|
||||||
|
@ApiModelProperty(value = "输送线最大容量")
|
||||||
|
private Integer maxNumber;
|
||||||
|
|
||||||
|
@Column(name = "`back_number`")
|
||||||
|
@ApiModelProperty(value = "输送线返库料箱数")
|
||||||
|
private Integer backNumber;
|
||||||
|
|
||||||
|
@Column(name = "`max_stock_number`")
|
||||||
|
@ApiModelProperty(value = "最大料箱任务数")
|
||||||
|
private Integer maxStockNumber;
|
||||||
|
|
||||||
|
@Column(name = "`dept_id`")
|
||||||
|
@ApiModelProperty(value = "仓库ID")
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
@Column(name = "`description`")
|
||||||
|
@ApiModelProperty(value = "描述")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@Column(name = "`enabled`")
|
||||||
|
@ApiModelProperty(value = "是否启用")
|
||||||
|
private Boolean enabled;
|
||||||
|
|
||||||
|
@Column(name = "`create_by`")
|
||||||
|
@ApiModelProperty(value = "创建人")
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
@Column(name = "`update_by`")
|
||||||
|
@ApiModelProperty(value = "修改人")
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
@Column(name = "`create_time`")
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
|
private Timestamp createTime;
|
||||||
|
|
||||||
|
@Column(name = "`update_time`")
|
||||||
|
@ApiModelProperty(value = "修改时间")
|
||||||
|
private Timestamp updateTime;
|
||||||
|
|
||||||
|
public void copy(WorkPoint source){
|
||||||
|
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Zheng Jie
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.youchain.basicdata.repository;
|
||||||
|
|
||||||
|
import com.youchain.basicdata.domain.WorkPoint;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @website https://eladmin.vip
|
||||||
|
* @author houjianlan
|
||||||
|
* @date 2024-09-26
|
||||||
|
**/
|
||||||
|
public interface WorkPointRepository extends JpaRepository<WorkPoint, Long>, JpaSpecificationExecutor<WorkPoint> {
|
||||||
|
/**
|
||||||
|
* 根据 Code 查询
|
||||||
|
* @param code /
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
WorkPoint findByCode(String code);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Zheng Jie
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.youchain.basicdata.rest;
|
||||||
|
|
||||||
|
import com.youchain.annotation.Log;
|
||||||
|
import com.youchain.basicdata.domain.WorkPoint;
|
||||||
|
import com.youchain.basicdata.service.WorkPointService;
|
||||||
|
import com.youchain.basicdata.service.dto.WorkPointQueryCriteria;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @website https://eladmin.vip
|
||||||
|
* @author houjianlan
|
||||||
|
* @date 2024-09-26
|
||||||
|
**/
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Api(tags = "workPoint管理")
|
||||||
|
@RequestMapping("/api/workPoint")
|
||||||
|
public class WorkPointController {
|
||||||
|
|
||||||
|
private final WorkPointService workPointService;
|
||||||
|
|
||||||
|
@Log("导出数据")
|
||||||
|
@ApiOperation("导出数据")
|
||||||
|
@GetMapping(value = "/download")
|
||||||
|
@PreAuthorize("@el.check('workPoint:list')")
|
||||||
|
public void exportWorkPoint(HttpServletResponse response, WorkPointQueryCriteria criteria) throws Exception {
|
||||||
|
workPointService.download(workPointService.queryAll(criteria), response);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
@Log("查询workPoint")
|
||||||
|
@ApiOperation("查询workPoint")
|
||||||
|
@PreAuthorize("@el.check('workPoint:list')")
|
||||||
|
public ResponseEntity<Object> queryWorkPoint(WorkPointQueryCriteria criteria, Pageable pageable){
|
||||||
|
return new ResponseEntity<>(workPointService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
@Log("新增workPoint")
|
||||||
|
@ApiOperation("新增workPoint")
|
||||||
|
@PreAuthorize("@el.check('workPoint:add')")
|
||||||
|
public ResponseEntity<Object> createWorkPoint(@Validated @RequestBody WorkPoint resources){
|
||||||
|
return new ResponseEntity<>(workPointService.create(resources),HttpStatus.CREATED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping
|
||||||
|
@Log("修改workPoint")
|
||||||
|
@ApiOperation("修改workPoint")
|
||||||
|
@PreAuthorize("@el.check('workPoint:edit')")
|
||||||
|
public ResponseEntity<Object> updateWorkPoint(@Validated @RequestBody WorkPoint resources){
|
||||||
|
workPointService.update(resources);
|
||||||
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping
|
||||||
|
@Log("删除workPoint")
|
||||||
|
@ApiOperation("删除workPoint")
|
||||||
|
@PreAuthorize("@el.check('workPoint:del')")
|
||||||
|
public ResponseEntity<Object> deleteWorkPoint(@RequestBody Long[] ids) {
|
||||||
|
workPointService.deleteAll(ids);
|
||||||
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,83 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Zheng Jie
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.youchain.basicdata.service;
|
||||||
|
|
||||||
|
import com.youchain.basicdata.domain.WorkPoint;
|
||||||
|
import com.youchain.basicdata.service.dto.WorkPointDto;
|
||||||
|
import com.youchain.basicdata.service.dto.WorkPointQueryCriteria;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.List;
|
||||||
|
import java.io.IOException;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @website https://eladmin.vip
|
||||||
|
* @description 服务接口
|
||||||
|
* @author houjianlan
|
||||||
|
* @date 2024-09-26
|
||||||
|
**/
|
||||||
|
public interface WorkPointService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询数据分页
|
||||||
|
* @param criteria 条件
|
||||||
|
* @param pageable 分页参数
|
||||||
|
* @return Map<String,Object>
|
||||||
|
*/
|
||||||
|
Map<String,Object> queryAll(WorkPointQueryCriteria criteria, Pageable pageable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有数据不分页
|
||||||
|
* @param criteria 条件参数
|
||||||
|
* @return List<WorkPointDto>
|
||||||
|
*/
|
||||||
|
List<WorkPointDto> queryAll(WorkPointQueryCriteria criteria);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ID查询
|
||||||
|
* @param id ID
|
||||||
|
* @return WorkPointDto
|
||||||
|
*/
|
||||||
|
WorkPointDto findById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建
|
||||||
|
* @param resources /
|
||||||
|
* @return WorkPointDto
|
||||||
|
*/
|
||||||
|
WorkPointDto create(WorkPoint resources);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑
|
||||||
|
* @param resources /
|
||||||
|
*/
|
||||||
|
void update(WorkPoint resources);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多选删除
|
||||||
|
* @param ids /
|
||||||
|
*/
|
||||||
|
void deleteAll(Long[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出数据
|
||||||
|
* @param all 待导出的数据
|
||||||
|
* @param response /
|
||||||
|
* @throws Exception /
|
||||||
|
*/
|
||||||
|
void download(List<WorkPointDto> all, HttpServletResponse response) throws Exception;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,90 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Zheng Jie
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.youchain.basicdata.service.dto;
|
||||||
|
|
||||||
|
import com.youchain.basicdata.domain.Area;
|
||||||
|
import com.youchain.basicdata.domain.Point;
|
||||||
|
import com.youchain.modules.system.domain.Dept;
|
||||||
|
import lombok.Data;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @website https://eladmin.vip
|
||||||
|
* @description /
|
||||||
|
* @author houjianlan
|
||||||
|
* @date 2024-09-26
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
public class WorkPointDto implements Serializable {
|
||||||
|
|
||||||
|
/** 主键 */
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 编码 */
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/** 名称 */
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/** 所属库区 */
|
||||||
|
private Area area;
|
||||||
|
|
||||||
|
/** 上料接驳口数 */
|
||||||
|
private Integer upNumber;
|
||||||
|
|
||||||
|
/** 上料接驳口 */
|
||||||
|
private Point upPoint;
|
||||||
|
|
||||||
|
/** 下料接驳口数 */
|
||||||
|
private Integer downNumber;
|
||||||
|
|
||||||
|
/** 下料接驳口 */
|
||||||
|
private Point downPoint;
|
||||||
|
|
||||||
|
/** 接驳口车辆数 */
|
||||||
|
private Integer agvNumber;
|
||||||
|
|
||||||
|
/** 输送线最大容量 */
|
||||||
|
private Integer maxNumber;
|
||||||
|
|
||||||
|
/** 输送线返库料箱数 */
|
||||||
|
private Integer backNumber;
|
||||||
|
|
||||||
|
/** 最大料箱任务数 */
|
||||||
|
private Integer maxStockNumber;
|
||||||
|
|
||||||
|
/** 仓库ID */
|
||||||
|
private Dept dept;
|
||||||
|
|
||||||
|
/** 描述 */
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
/** 是否启用 */
|
||||||
|
private Boolean enabled;
|
||||||
|
|
||||||
|
/** 创建人 */
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
/** 修改人 */
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
/** 创建时间 */
|
||||||
|
private Timestamp createTime;
|
||||||
|
|
||||||
|
/** 修改时间 */
|
||||||
|
private Timestamp updateTime;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Zheng Jie
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.youchain.basicdata.service.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import java.util.List;
|
||||||
|
import com.youchain.annotation.Query;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @website https://eladmin.vip
|
||||||
|
* @author houjianlan
|
||||||
|
* @date 2024-09-26
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
public class WorkPointQueryCriteria{
|
||||||
|
|
||||||
|
/** 模糊 */
|
||||||
|
@Query(type = Query.Type.INNER_LIKE)
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/** 精确 */
|
||||||
|
@Query
|
||||||
|
private Long areaId;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,105 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Zheng Jie
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.youchain.basicdata.service.impl;
|
||||||
|
|
||||||
|
import com.youchain.basicdata.domain.WorkPoint;
|
||||||
|
import com.youchain.exception.EntityExistException;
|
||||||
|
import com.youchain.utils.*;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import com.youchain.basicdata.repository.WorkPointRepository;
|
||||||
|
import com.youchain.basicdata.service.WorkPointService;
|
||||||
|
import com.youchain.basicdata.service.dto.WorkPointDto;
|
||||||
|
import com.youchain.basicdata.service.dto.WorkPointQueryCriteria;
|
||||||
|
import com.youchain.basicdata.service.mapstruct.WorkPointMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.io.IOException;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @website https://eladmin.vip
|
||||||
|
* @description 服务实现
|
||||||
|
* @author houjianlan
|
||||||
|
* @date 2024-09-26
|
||||||
|
**/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class WorkPointServiceImpl implements WorkPointService {
|
||||||
|
|
||||||
|
private final WorkPointRepository workPointRepository;
|
||||||
|
private final WorkPointMapper workPointMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String,Object> queryAll(WorkPointQueryCriteria criteria, Pageable pageable){
|
||||||
|
Page<WorkPoint> page = workPointRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||||
|
return PageUtil.toPage(page.map(workPointMapper::toDto));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<WorkPointDto> queryAll(WorkPointQueryCriteria criteria){
|
||||||
|
return workPointMapper.toDto(workPointRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public WorkPointDto findById(Long id) {
|
||||||
|
WorkPoint workPoint = workPointRepository.findById(id).orElseGet(WorkPoint::new);
|
||||||
|
ValidationUtil.isNull(workPoint.getId(),"WorkPoint","id",id);
|
||||||
|
return workPointMapper.toDto(workPoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public WorkPointDto create(WorkPoint resources) {
|
||||||
|
if(workPointRepository.findByCode(resources.getCode()) != null){
|
||||||
|
throw new EntityExistException(WorkPoint.class,"code",resources.getCode());
|
||||||
|
}
|
||||||
|
return workPointMapper.toDto(workPointRepository.save(resources));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void update(WorkPoint resources) {
|
||||||
|
WorkPoint workPoint = workPointRepository.findById(resources.getId()).orElseGet(WorkPoint::new);
|
||||||
|
ValidationUtil.isNull( workPoint.getId(),"WorkPoint","id",resources.getId());
|
||||||
|
WorkPoint workPoint1 = null;
|
||||||
|
workPoint1 = workPointRepository.findByCode(resources.getCode());
|
||||||
|
if(workPoint1 != null && !workPoint1.getId().equals(workPoint.getId())){
|
||||||
|
throw new EntityExistException(WorkPoint.class,"code",resources.getCode());
|
||||||
|
}
|
||||||
|
workPoint.copy(resources);
|
||||||
|
workPointRepository.save(workPoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteAll(Long[] ids) {
|
||||||
|
for (Long id : ids) {
|
||||||
|
workPointRepository.deleteById(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void download(List<WorkPointDto> all, HttpServletResponse response) throws Exception {
|
||||||
|
List<Map<String, Object>> list= ExcelDownUtils.CreateMap(all,"WorkPoint");
|
||||||
|
FileUtil.downloadExcel(list, response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Zheng Jie
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.youchain.basicdata.service.mapstruct;
|
||||||
|
|
||||||
|
import com.youchain.base.BaseMapper;
|
||||||
|
import com.youchain.basicdata.domain.WorkPoint;
|
||||||
|
import com.youchain.basicdata.service.dto.WorkPointDto;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.ReportingPolicy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @website https://eladmin.vip
|
||||||
|
* @author houjianlan
|
||||||
|
* @date 2024-09-26
|
||||||
|
**/
|
||||||
|
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||||
|
public interface WorkPointMapper extends BaseMapper<WorkPointDto, WorkPoint> {
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue