Commit 65294637 authored by dahai's avatar dahai

添加绿包运单信息的上传、查询、删除

parent 03b72d27
package com.yxproject.start.api;
import com.yxproject.start.entity.GreenPackageInformationFileEntity;
import com.yxproject.start.service.GreenPackageInformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @auther zhangyusheng
* 2019/6/19 11:07
*/
@RestController
@RequestMapping("GreenPackageInformationApi")
public class GreenPackageInformationApi {
@Autowired
GreenPackageInformationService greenPackageInformationService;
/**
* 查询提交的绿包信息表
* @param startDate 起始时间
* @param endDate 截至时间
* @param name 查询人姓名
* @return
*/
@RequestMapping("queryGreenPackageInformationFile")
public List<GreenPackageInformationFileEntity> queryGreenPackageInformationFileEntity(@RequestParam("startDate") String startDate,@RequestParam("endDate") String endDate,@RequestParam("name") String name ){
List<GreenPackageInformationFileEntity> greenPackageInformationFileEntities = greenPackageInformationService.selectGreenPackageInformationFileEntity(replaceDate(startDate), replaceDate(endDate), replaceNullString(name));
return greenPackageInformationFileEntities;
}
/**
* 删除提交的绿包信息表
* @param id 流水号
* @return
*/
@RequestMapping("deleteGreenPackageInformationFile")
public boolean deleteGreenPackageInformationFileEntity(@RequestParam("id") String id ){
boolean b = greenPackageInformationService.deleteGreenPackageInformationFileEntity(id);
return b;
}
/**
* 字符串去除空格
*
* @param str 原始字符串
* @return 返回新的字符串
*/
private String replaceNullString(String str) {
if (str == "") {
return null;
} else return str;
}
/**
* 去除字符串中中线
*
* @param str
* @return
*/
private String replaceDate(String str) {
return str.replace("-", "").replace(" ", "").replace(":", "");
}
}
package com.yxproject.start.entity;
import javax.persistence.*;
import java.util.Objects;
/**
* @auther zhangyusheng
* 2019/6/18 14:45
*/
@Entity
@Table(name = "GREEN_PACKAGE_INFORMATION", schema = "YINGXIN", catalog = "")
public class GreenPackageInformationEntity {
private long id;
private String waybillNumber;
private String policeName;
private String receiptDate;
private long fileId;
@Id
@Column(name = "ID")
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@Basic
@Column(name = "WAYBILL_NUMBER")
public String getWaybillNumber() {
return waybillNumber;
}
public void setWaybillNumber(String waybillNumber) {
this.waybillNumber = waybillNumber;
}
@Basic
@Column(name = "POLICE_NAME")
public String getPoliceName() {
return policeName;
}
public void setPoliceName(String policeName) {
this.policeName = policeName;
}
@Basic
@Column(name = "RECEIPT_DATE")
public String getReceiptDate() {
return receiptDate;
}
public void setReceiptDate(String receiptDate) {
this.receiptDate = receiptDate;
}
@Basic
@Column(name = "FILE_ID")
public long getFileId() {
return fileId;
}
public void setFileId(long fileId) {
this.fileId = fileId;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
GreenPackageInformationEntity that = (GreenPackageInformationEntity) o;
return id == that.id &&
Objects.equals(waybillNumber, that.waybillNumber) &&
Objects.equals(policeName, that.policeName) &&
Objects.equals(fileId, that.fileId) &&
Objects.equals(receiptDate, that.receiptDate);
}
@Override
public int hashCode() {
return Objects.hash(id, waybillNumber, policeName,fileId, receiptDate);
}
}
package com.yxproject.start.entity;
import javax.persistence.*;
import java.util.Date;
import java.util.Objects;
/**
* @auther zhangyusheng
* 2019/6/19 11:02
*/
@Entity
@Table(name = "GREEN_PACKAGE_INFORMATION_FILE", schema = "YINGXIN", catalog = "")
public class GreenPackageInformationFileEntity {
private long id;
private String fileName;
private Date importDate;
private String importName;
@Id
@Column(name = "ID")
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@Basic
@Column(name = "FILE_NAME")
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
@Basic
@Column(name = "IMPORT_DATE")
public Date getImportDate() {
return importDate;
}
public void setImportDate(Date importDate) {
this.importDate = importDate;
}
@Basic
@Column(name = "IMPORT_NAME")
public String getImportName() {
return importName;
}
public void setImportName(String importName) {
this.importName = importName;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
GreenPackageInformationFileEntity that = (GreenPackageInformationFileEntity) o;
return id == that.id &&
Objects.equals(fileName, that.fileName) &&
Objects.equals(importDate, that.importDate) &&
Objects.equals(importName, that.importName);
}
@Override
public int hashCode() {
return Objects.hash(id, fileName, importDate, importName);
}
}
package com.yxproject.start.mapper;
import com.yxproject.start.entity.GreenPackageInformationFileEntity;
import org.apache.ibatis.annotations.*;
import java.util.List;
/**
* @auther zhangyusheng
* 2019/6/19 10:40
*/
@Mapper
public interface GreenPackageInformationFileMapper {
@Insert("insert into GREEN_PACKAGE_INFORMATION_FILE (FILE_NAME,IMPORT_DATE,IMPORT_NAME) values (#{fileName},sysdate,#{importName})")
@Options(useGeneratedKeys=true, keyProperty="id", keyColumn="ID")
public boolean saveGreenPackageInformationFile(GreenPackageInformationFileEntity greenPackageInformationFileEntity);
@Select("<script> select * from GREEN_PACKAGE_INFORMATION_FILE " +
"where to_char(IMPORT_DATE,'yyyyMMdd') between #{startDate} and #{endDate} " +
"<if test = 'name != null'> " +
" and IMPORT_NAME = #{name} " +
" </if>" +
"</script>")
public List<GreenPackageInformationFileEntity> selectGreenPackageInformationFileEntity(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("name") String name);
@Delete("DELETE from GREEN_PACKAGE_INFORMATION_FILE WHERE id = #{id}")
public boolean deleteGreenPackageInformationFileEntity(@Param("id") long id);
}
package com.yxproject.start.mapper;
import com.yxproject.start.entity.GreenPackageInformationEntity;
import org.apache.ibatis.annotations.*;
import java.util.List;
import java.util.Map;
/**
* @auther zhangyusheng
* 2019/6/18 14:47
*/
@Mapper
public interface GreenPackageInformationMapper {
@Select("select * from GAJG_DM where GAJG_MC like #{policeName}")
public List<Map<String,Object>> selectPolice(@Param("policeName") String policeName);
@Insert("insert into GREEN_PACKAGE_INFORMATION (WAYBILL_NUMBER,POLICE_NAME,RECEIPT_DATE,file_id) VALUES(#{waybillNumber},#{policeName},#{receiptDate},#{fileId})")
public boolean saveGreenPackageInformation(GreenPackageInformationEntity greenPackageInformationEntity);
@Delete("delete from GREEN_PACKAGE_INFORMATION where file_id = #{fileId}")
public boolean deleteGreenPackageInformationByFileId(@Param("fileId") long fileId);
}
package com.yxproject.start.service;
import com.yxproject.start.entity.GreenPackageInformationEntity;
import com.yxproject.start.entity.GreenPackageInformationFileEntity;
import java.util.List;
/**
* @auther zhangyusheng
* 2019/6/18 14:48
*/
public interface GreenPackageInformationService {
public boolean saveGreenPackageInformation(GreenPackageInformationEntity greenPackageInformationEntity);
public long saveGreenPackageInformationFile(GreenPackageInformationFileEntity greenPackageInformationFileEntity);
public List<GreenPackageInformationFileEntity> selectGreenPackageInformationFileEntity(String startDate, String endDate, String name);
public boolean deleteGreenPackageInformationFileEntity(String id);
}
package com.yxproject.start.service.impl;
import com.yxproject.start.entity.GreenPackageInformationEntity;
import com.yxproject.start.entity.GreenPackageInformationFileEntity;
import com.yxproject.start.mapper.GreenPackageInformationFileMapper;
import com.yxproject.start.mapper.GreenPackageInformationMapper;
import com.yxproject.start.service.GreenPackageInformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* @auther zhangyusheng
* 2019/6/18 14:49
*/
@Service
public class GreenPackageInformationServiceImpl implements GreenPackageInformationService {
@Autowired
private GreenPackageInformationMapper greenPackageInformationMapper;
@Autowired
private GreenPackageInformationFileMapper greenPackageInformationFileMapper;
@Override
public boolean saveGreenPackageInformation(GreenPackageInformationEntity greenPackageInformationEntity) {
List<Map<String, Object>> list = greenPackageInformationMapper.selectPolice("'%" + greenPackageInformationEntity.getPoliceName() + "%'");
if (list.size()>0){
return greenPackageInformationMapper.saveGreenPackageInformation(greenPackageInformationEntity);
}else {
return false;
}
}
@Override
public long saveGreenPackageInformationFile(GreenPackageInformationFileEntity greenPackageInformationFileEntity) {
boolean b = greenPackageInformationFileMapper.saveGreenPackageInformationFile(greenPackageInformationFileEntity);
return greenPackageInformationFileEntity.getId();
}
@Override
public List<GreenPackageInformationFileEntity> selectGreenPackageInformationFileEntity(String startDate, String endDate, String name) {
List<GreenPackageInformationFileEntity> greenPackageInformationFileEntities = greenPackageInformationFileMapper.selectGreenPackageInformationFileEntity(startDate, endDate, name);
return greenPackageInformationFileEntities;
}
@Override
public boolean deleteGreenPackageInformationFileEntity(String id) {
greenPackageInformationMapper.deleteGreenPackageInformationByFileId(Long.valueOf(id));
greenPackageInformationFileMapper.deleteGreenPackageInformationFileEntity(Long.valueOf(id));
return true;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment