Просмотр исходного кода

收费标准模块完成
发运单模块加入目的地
发运单详情模块加入类型

jz.kai 2 лет назад
Родитель
Сommit
1f7ce4ee10

+ 18 - 0
common/src/main/java/com/jpsoft/prices/modules/base/dao/StandardDAO.java

@@ -0,0 +1,18 @@
+package com.jpsoft.prices.modules.base.dao;
+
+import java.util.List;
+import org.springframework.stereotype.Repository;
+import com.jpsoft.prices.modules.base.entity.Standard;
+import java.util.Map;
+import com.jpsoft.prices.modules.common.dto.Sort;
+
+@Repository
+public interface StandardDAO {
+	int insert(Standard entity);
+	int update(Standard entity);
+	int exist(String id);
+	Standard get(String id);
+	int delete(String id);
+	List<Standard> list();
+	List<Standard> search(Map<String,Object> searchParams,List<Sort> sortList);
+}

+ 64 - 0
common/src/main/java/com/jpsoft/prices/modules/base/entity/Standard.java

@@ -0,0 +1,64 @@
+package com.jpsoft.prices.modules.base.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.text.SimpleDateFormat;
+import java.math.BigDecimal;
+import org.springframework.format.annotation.DateTimeFormat;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+/**
+  描述:base_standard的实体类
+ */
+@Data
+@ApiModel(value = "base_standard的实体类")
+public class Standard {
+        @ApiModelProperty(value = "编号")
+    private String id;
+        @ApiModelProperty(value = "物流公司编号")
+    private String companyId;
+    private String companyName;
+        @ApiModelProperty(value = "目的地编号")
+    private String destinationId;
+    private String destinationName;
+        @ApiModelProperty(value = "运费逻辑编号")
+    private String logicId;
+    private String logicName;
+        @ApiModelProperty(value = "名称")
+    private String name;
+        @ApiModelProperty(value = "首重")
+    private BigDecimal firstWeight;
+        @ApiModelProperty(value = "单价")
+    private BigDecimal unitPrice;
+        @ApiModelProperty(value = "单位")
+    private String unitName;
+        @ApiModelProperty(value = "起步价")
+    private BigDecimal startingPrice;
+        @ApiModelProperty(value = "浮动价")
+    private BigDecimal floatingPrice;
+        @ApiModelProperty(value = "送货费")
+    private BigDecimal deliveryFee;
+        @ApiModelProperty(value = "进仓费")
+    private BigDecimal storageFee;
+        @ApiModelProperty(value = "保费")
+    private BigDecimal insureFee;
+        @ApiModelProperty(value = "税费")
+    private BigDecimal taxFee;
+        @ApiModelProperty(value = "是否删除")
+    private Boolean delFlag;
+        @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
+	    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+        @ApiModelProperty(value = "创建人")
+    private String createBy;
+        @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
+	    @ApiModelProperty(value = "更新时间")
+    private Date updateTime;
+        @ApiModelProperty(value = "更新人")
+    private String updateBy;
+}

+ 17 - 0
common/src/main/java/com/jpsoft/prices/modules/base/service/StandardService.java

@@ -0,0 +1,17 @@
+package com.jpsoft.prices.modules.base.service;
+
+import java.util.List;
+import java.util.Map;
+import com.jpsoft.prices.modules.base.entity.Standard;
+import com.github.pagehelper.Page;
+import com.jpsoft.prices.modules.common.dto.Sort;
+
+public interface StandardService {
+	Standard get(String id);
+	boolean exist(String id);
+	int insert(Standard model);
+	int update(Standard model);
+	int delete(String id);
+	List<Standard> list();
+	Page<Standard> pageSearch(Map<String, Object> searchParams,int pageNum,int pageSize,boolean count,List<Sort> sortList);
+}

+ 70 - 0
common/src/main/java/com/jpsoft/prices/modules/base/service/impl/StandardServiceImpl.java

@@ -0,0 +1,70 @@
+package com.jpsoft.prices.modules.base.service.impl;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import javax.annotation.Resource;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+import com.jpsoft.prices.modules.base.dao.StandardDAO;
+import com.jpsoft.prices.modules.base.entity.Standard;
+import com.jpsoft.prices.modules.base.service.StandardService;
+import com.github.pagehelper.Page;
+import com.jpsoft.prices.modules.common.dto.Sort;
+import com.github.pagehelper.PageHelper;
+
+@Transactional
+@Component(value="standardService")
+public class StandardServiceImpl implements StandardService {
+	@Resource(name="standardDAO")
+	private StandardDAO standardDAO;
+
+	@Override
+	public Standard get(String id) {
+		// TODO Auto-generated method stub
+		return standardDAO.get(id);
+	}
+
+	@Override
+	public int insert(Standard model) {
+		// TODO Auto-generated method stub
+		//model.setId(UUID.randomUUID().toString());
+		
+		return standardDAO.insert(model);
+	}
+
+	@Override
+	public int update(Standard model) {
+		// TODO Auto-generated method stub
+		return standardDAO.update(model);		
+	}
+
+	@Override
+	public int delete(String id) {
+		// TODO Auto-generated method stub
+		return standardDAO.delete(id);
+	}
+
+	@Override
+	public boolean exist(String id) {
+		// TODO Auto-generated method stub
+		int count = standardDAO.exist(id);
+		
+		return count > 0 ? true : false;
+	}
+	
+	@Override
+	public List<Standard> list() {
+		// TODO Auto-generated method stub
+		return standardDAO.list();
+	}
+		
+	@Override
+	public Page<Standard> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,boolean count,List<Sort> sortList) {
+        Page<Standard> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
+            standardDAO.search(searchParams,sortList);
+        });
+        
+        return page;
+	}
+}

+ 163 - 0
common/src/main/resources/mapper/base/Standard.xml

@@ -0,0 +1,163 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<!-- namespace必须指向DAO接口 -->
+<mapper namespace="com.jpsoft.prices.modules.base.dao.StandardDAO">
+	<resultMap id="StandardMap" type="com.jpsoft.prices.modules.base.entity.Standard">
+		<id property="id" column="id_" />
+		<result property="companyId" column="company_id" />
+		<result property="destinationId" column="destination_id" />
+		<result property="logicId" column="logic_id" />
+		<result property="name" column="name_" />
+		<result property="firstWeight" column="first_weight" />
+		<result property="unitPrice" column="unit_price" />
+		<result property="unitName" column="unit_name" />
+		<result property="startingPrice" column="starting_price" />
+		<result property="floatingPrice" column="floating_price" />
+		<result property="deliveryFee" column="delivery_fee" />
+		<result property="storageFee" column="storage_fee" />
+		<result property="insureFee" column="insure_fee" />
+		<result property="taxFee" column="tax_fee" />
+		<result property="delFlag" column="del_flag" />
+		<result property="createTime" column="create_time" />
+		<result property="createBy" column="create_by" />
+		<result property="updateTime" column="update_time" />
+		<result property="updateBy" column="update_by" />
+
+		<result property="companyName" column="company_name" />
+		<result property="destinationName" column="destination_name" />
+		<result property="logicName" column="logic_name" />
+	</resultMap>
+	<insert id="insert" parameterType="com.jpsoft.prices.modules.base.entity.Standard">
+	<!--
+	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
+		select sys_guid() from dual
+	</selectKey>
+	-->
+	<![CDATA[
+		insert into base_standard
+	    (id_,company_id,destination_id,logic_id,name_,first_weight,unit_price,unit_name,starting_price,floating_price,delivery_fee,storage_fee,insure_fee,tax_fee,del_flag,create_time,create_by,update_time,update_by)
+		values
+		(
+#{id,jdbcType=VARCHAR}
+,#{companyId,jdbcType=VARCHAR}
+,#{destinationId,jdbcType=VARCHAR}
+,#{logicId,jdbcType=VARCHAR}
+,#{name,jdbcType=VARCHAR}
+,#{firstWeight,jdbcType= NUMERIC }
+,#{unitPrice,jdbcType= NUMERIC }
+,#{unitName,jdbcType=VARCHAR}
+,#{startingPrice,jdbcType= NUMERIC }
+,#{floatingPrice,jdbcType= NUMERIC }
+,#{deliveryFee,jdbcType= NUMERIC }
+,#{storageFee,jdbcType= NUMERIC }
+,#{insureFee,jdbcType= NUMERIC }
+,#{taxFee,jdbcType= NUMERIC }
+,#{delFlag,jdbcType= NUMERIC }
+,#{createTime,jdbcType= TIMESTAMP }
+,#{createBy,jdbcType=VARCHAR}
+,#{updateTime,jdbcType= TIMESTAMP }
+,#{updateBy,jdbcType=VARCHAR}
+		)
+	]]>
+	</insert>
+	<delete id="delete" parameterType="string">
+		delete from base_standard where id_=#{id,jdbcType=VARCHAR}
+	</delete>
+	<update id="update" parameterType="com.jpsoft.prices.modules.base.entity.Standard">
+		update base_standard
+		<set>
+				<if test="companyId!=null">
+		company_id=#{companyId,jdbcType=VARCHAR},
+		</if>
+				<if test="destinationId!=null">
+		destination_id=#{destinationId,jdbcType=VARCHAR},
+		</if>
+				<if test="logicId!=null">
+		logic_id=#{logicId,jdbcType=VARCHAR},
+		</if>
+				<if test="name!=null">
+		name_=#{name,jdbcType=VARCHAR},
+		</if>
+				<if test="firstWeight!=null">
+		first_weight=#{firstWeight,jdbcType= NUMERIC },
+		</if>
+				<if test="unitPrice!=null">
+		unit_price=#{unitPrice,jdbcType= NUMERIC },
+		</if>
+				<if test="unitName!=null">
+		unit_name=#{unitName,jdbcType=VARCHAR},
+		</if>
+				<if test="startingPrice!=null">
+		starting_price=#{startingPrice,jdbcType= NUMERIC },
+		</if>
+				<if test="floatingPrice!=null">
+		floating_price=#{floatingPrice,jdbcType= NUMERIC },
+		</if>
+				<if test="deliveryFee!=null">
+		delivery_fee=#{deliveryFee,jdbcType= NUMERIC },
+		</if>
+				<if test="storageFee!=null">
+		storage_fee=#{storageFee,jdbcType= NUMERIC },
+		</if>
+				<if test="insureFee!=null">
+		insure_fee=#{insureFee,jdbcType= NUMERIC },
+		</if>
+				<if test="taxFee!=null">
+		tax_fee=#{taxFee,jdbcType= NUMERIC },
+		</if>
+				<if test="delFlag!=null">
+		del_flag=#{delFlag,jdbcType= NUMERIC },
+		</if>
+				<if test="createTime!=null">
+		create_time=#{createTime,jdbcType= TIMESTAMP },
+		</if>
+				<if test="createBy!=null">
+		create_by=#{createBy,jdbcType=VARCHAR},
+		</if>
+				<if test="updateTime!=null">
+		update_time=#{updateTime,jdbcType= TIMESTAMP },
+		</if>
+				<if test="updateBy!=null">
+		update_by=#{updateBy,jdbcType=VARCHAR},
+		</if>
+		</set>
+	where id_=#{id}
+	</update>
+	<select id="get" parameterType="string" resultMap="StandardMap">
+		select 
+id_,company_id,destination_id,logic_id,name_,first_weight,unit_price,unit_name,starting_price,floating_price,delivery_fee,storage_fee,insure_fee,tax_fee,del_flag,create_time,create_by,update_time,update_by		from base_standard where id_=#{0}
+	</select>
+	<select id="exist" parameterType="string" resultType="int">
+		select count(*) from base_standard where id_=#{0}
+	</select>
+	<select id="list" resultMap="StandardMap">
+		select * from base_standard
+	</select>
+	<select id="search" parameterType="hashmap" resultMap="StandardMap">
+		<![CDATA[
+			SELECT a.*,b.name_ AS company_name,c.name_ AS destination_name,d.name_ AS logic_name FROM base_standard a
+			LEFT JOIN base_company b ON a.company_id = b.id_
+			LEFT JOIN  base_destination c ON a.destination_id = c.id_
+			LEFT JOIN sys_data_dictionary d ON a.logic_id = d.id_
+		]]>
+		<where>
+			a.del_flag = 0
+			<if test="searchParams.name != null">
+				and a.name_ like #{searchParams.name}
+			</if>
+			<if test="searchParams.companyId != null">
+				and a.company_id = #{searchParams.companyId}
+			</if>
+			<if test="searchParams.destinationId != null">
+				and a.destination_id = #{searchParams.destinationId}
+			</if>
+			<if test="searchParams.logicId != null">
+				and a.logic_id = #{searchParams.logicId}
+			</if>
+		</where>
+		<foreach item="sort" collection="sortList"  open="order by" separator=",">
+	        ${sort.name} ${sort.order}
+	 	</foreach>
+	</select>
+</mapper>

+ 228 - 0
web/src/main/java/com/jpsoft/prices/modules/base/controller/StandardController.java

@@ -0,0 +1,228 @@
+package com.jpsoft.prices.modules.base.controller;
+
+import com.github.pagehelper.Page;
+import com.jpsoft.prices.modules.common.utils.PojoUtils;
+import com.jpsoft.prices.modules.common.dto.Sort;
+import com.jpsoft.prices.modules.common.dto.MessageResult;
+import com.jpsoft.prices.modules.base.entity.Standard;
+import com.jpsoft.prices.modules.base.service.StandardService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+@RestController
+@RequestMapping("/base/standard")
+@Api(description = "standard")
+public class StandardController {
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    @Autowired
+    private StandardService standardService;
+
+    @ApiOperation(value="创建空记录")
+    @GetMapping("create")
+    public MessageResult<Standard> create(){
+        MessageResult<Standard> msgResult = new MessageResult<>();
+
+        Standard standard = new Standard();
+
+        msgResult.setData(standard);
+        msgResult.setResult(true);
+
+        return msgResult;
+    }
+    
+    @ApiOperation(value="添加信息")
+    @PostMapping("add")
+    public MessageResult<Standard> add(@RequestBody Standard standard,@RequestAttribute String subject){
+        MessageResult<Standard> msgResult = new MessageResult<>();
+
+        try {
+            standard.setId(UUID.randomUUID().toString());
+            standard.setDelFlag(false);
+            standard.setCreateBy(subject);
+            standard.setCreateTime(new Date());
+            
+            int affectCount = standardService.insert(standard);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(standard);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库添加失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="获取信息")
+    @GetMapping("edit/{id}")
+    public MessageResult<Standard> edit(@PathVariable("id") String id){
+        MessageResult<Standard> msgResult = new MessageResult<>();
+
+        try {
+            Standard standard = standardService.get(id);
+
+            if (standard != null) {
+                msgResult.setResult(true);
+                msgResult.setData(standard);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库不存在该记录!");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="更新用户")
+    @PostMapping("update")
+    public MessageResult<Standard> update(@RequestBody Standard standard,@RequestAttribute String subject){
+        MessageResult<Standard> msgResult = new MessageResult<>();
+
+        try {
+            standard.setUpdateBy(subject);
+            standard.setUpdateTime(new Date());
+            
+            int affectCount = standardService.update(standard);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(standard);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库更新失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+	@ApiOperation(value="删除")
+    @PostMapping("delete/{id}")
+    public MessageResult<Integer> delete(@PathVariable("id") String id,@RequestAttribute String subject){
+        MessageResult<Integer> msgResult = new MessageResult<>();
+
+        try {
+            Standard standard = standardService.get(id);
+            standard.setDelFlag(true);
+            standard.setUpdateBy(subject);
+            standard.setUpdateTime(new Date());
+
+            int affectCount = standardService.update(standard);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(affectCount);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("删除失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+
+    @ApiOperation(value="批量删除")
+    @PostMapping("batchDelete")
+    public MessageResult<Integer> batchDelete(@RequestBody List<String> idList,@RequestAttribute String subject){
+        MessageResult<Integer> msgResult = new MessageResult<>();
+
+        try {
+            int affectCount = 0;
+
+            for (String id : idList) {
+                Standard standard = standardService.get(id);
+                standard.setDelFlag(true);
+                standard.setUpdateBy(subject);
+                standard.setUpdateTime(new Date());
+
+                affectCount += standardService.update(standard);
+            }
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(affectCount);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("删除失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="列表")
+    @RequestMapping(value = "pageList",method = RequestMethod.POST)
+    public MessageResult<Map> pageList(
+            String name, String companyId, String destinationId, String logicId,
+            @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
+            @RequestParam(value="pageSize",defaultValue="20") int pageSize){
+        MessageResult<Map> msgResult = new MessageResult<>();
+
+        Map<String,Object> searchParams = new HashMap<>();
+        if (StringUtils.isNotEmpty(name)) {
+            searchParams.put("name","%" + name + "%");
+        }
+        if (StringUtils.isNotEmpty(companyId)) {
+            searchParams.put("companyId",companyId);
+        }
+        if (StringUtils.isNotEmpty(destinationId) && !"null".equals(destinationId)) {
+            searchParams.put("destinationId",destinationId);
+        }
+        if (StringUtils.isNotEmpty(logicId)) {
+            searchParams.put("logicId",logicId);
+        }
+
+        List<Sort> sortList = new ArrayList<>();
+        sortList.add(new Sort("a.create_time","asc"));
+
+        Page<Standard> page = standardService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
+
+        msgResult.setResult(true);
+        msgResult.setData(PojoUtils.pageWrapper(page));
+
+        return msgResult;
+    }
+}