瀏覽代碼

物流公司信息管理

jz.kai 2 年之前
父節點
當前提交
0ba15476a6

+ 18 - 0
common/src/main/java/com/jpsoft/prices/modules/base/dao/CompanyDAO.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.Company;
+import java.util.Map;
+import com.jpsoft.prices.modules.common.dto.Sort;
+
+@Repository
+public interface CompanyDAO {
+	int insert(Company entity);
+	int update(Company entity);
+	int exist(String id);
+	Company get(String id);
+	int delete(String id);
+	List<Company> list();
+	List<Company> search(Map<String,Object> searchParams,List<Sort> sortList);
+}

+ 19 - 0
common/src/main/java/com/jpsoft/prices/modules/base/dao/CompanyDestinationDAO.java

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

+ 45 - 0
common/src/main/java/com/jpsoft/prices/modules/base/entity/Company.java

@@ -0,0 +1,45 @@
+package com.jpsoft.prices.modules.base.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.text.SimpleDateFormat;
+import java.math.BigDecimal;
+import java.util.List;
+
+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_company的实体类
+ */
+@Data
+@ApiModel(value = "base_company的实体类")
+public class Company {
+        @ApiModelProperty(value = "编号")
+    private String id;
+        @ApiModelProperty(value = "名称")
+    private String name;
+        @ApiModelProperty(value = "备注")
+    private String remark;
+        @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;
+
+    @ApiModelProperty(value = "目的地")
+    private List<List<String>> destinationIds;
+    private String destinationNames;
+}

+ 25 - 0
common/src/main/java/com/jpsoft/prices/modules/base/entity/CompanyDestination.java

@@ -0,0 +1,25 @@
+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_company_destination的实体类
+ */
+@Data
+@ApiModel(value = "base_company_destination的实体类")
+public class CompanyDestination {
+        @ApiModelProperty(value = "编号")
+    private String id;
+        @ApiModelProperty(value = "公司编号")
+    private String companyId;
+        @ApiModelProperty(value = "目的地编号")
+    private String destinationId;
+}

+ 18 - 0
common/src/main/java/com/jpsoft/prices/modules/base/service/CompanyDestinationService.java

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

+ 17 - 0
common/src/main/java/com/jpsoft/prices/modules/base/service/CompanyService.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.Company;
+import com.github.pagehelper.Page;
+import com.jpsoft.prices.modules.common.dto.Sort;
+
+public interface CompanyService {
+	Company get(String id);
+	boolean exist(String id);
+	int insert(Company model);
+	int update(Company model);
+	int delete(String id);
+	List<Company> list();
+	Page<Company> pageSearch(Map<String, Object> searchParams,int pageNum,int pageSize,boolean count,List<Sort> sortList);
+}

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

@@ -0,0 +1,76 @@
+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.CompanyDestinationDAO;
+import com.jpsoft.prices.modules.base.entity.CompanyDestination;
+import com.jpsoft.prices.modules.base.service.CompanyDestinationService;
+import com.github.pagehelper.Page;
+import com.jpsoft.prices.modules.common.dto.Sort;
+import com.github.pagehelper.PageHelper;
+
+@Transactional
+@Component(value="companyDestinationService")
+public class CompanyDestinationServiceImpl implements CompanyDestinationService {
+	@Resource(name="companyDestinationDAO")
+	private CompanyDestinationDAO companyDestinationDAO;
+
+	@Override
+	public CompanyDestination get(String id) {
+		// TODO Auto-generated method stub
+		return companyDestinationDAO.get(id);
+	}
+
+	@Override
+	public int insert(CompanyDestination model) {
+		// TODO Auto-generated method stub
+		//model.setId(UUID.randomUUID().toString());
+		
+		return companyDestinationDAO.insert(model);
+	}
+
+	@Override
+	public int update(CompanyDestination model) {
+		// TODO Auto-generated method stub
+		return companyDestinationDAO.update(model);		
+	}
+
+	@Override
+	public int delete(String id) {
+		// TODO Auto-generated method stub
+		return companyDestinationDAO.delete(id);
+	}
+
+	@Override
+	public boolean exist(String id) {
+		// TODO Auto-generated method stub
+		int count = companyDestinationDAO.exist(id);
+		
+		return count > 0 ? true : false;
+	}
+	
+	@Override
+	public List<CompanyDestination> list() {
+		// TODO Auto-generated method stub
+		return companyDestinationDAO.list();
+	}
+		
+	@Override
+	public Page<CompanyDestination> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,boolean count,List<Sort> sortList) {
+        Page<CompanyDestination> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
+            companyDestinationDAO.search(searchParams,sortList);
+        });
+        
+        return page;
+	}
+
+	@Override
+	public List<CompanyDestination> findByCompany(String companyId) {
+		// TODO Auto-generated method stub
+		return companyDestinationDAO.findByCompany(companyId);
+	}
+}

+ 70 - 0
common/src/main/java/com/jpsoft/prices/modules/base/service/impl/CompanyServiceImpl.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.CompanyDAO;
+import com.jpsoft.prices.modules.base.entity.Company;
+import com.jpsoft.prices.modules.base.service.CompanyService;
+import com.github.pagehelper.Page;
+import com.jpsoft.prices.modules.common.dto.Sort;
+import com.github.pagehelper.PageHelper;
+
+@Transactional
+@Component(value="companyService")
+public class CompanyServiceImpl implements CompanyService {
+	@Resource(name="companyDAO")
+	private CompanyDAO companyDAO;
+
+	@Override
+	public Company get(String id) {
+		// TODO Auto-generated method stub
+		return companyDAO.get(id);
+	}
+
+	@Override
+	public int insert(Company model) {
+		// TODO Auto-generated method stub
+		//model.setId(UUID.randomUUID().toString());
+		
+		return companyDAO.insert(model);
+	}
+
+	@Override
+	public int update(Company model) {
+		// TODO Auto-generated method stub
+		return companyDAO.update(model);		
+	}
+
+	@Override
+	public int delete(String id) {
+		// TODO Auto-generated method stub
+		return companyDAO.delete(id);
+	}
+
+	@Override
+	public boolean exist(String id) {
+		// TODO Auto-generated method stub
+		int count = companyDAO.exist(id);
+		
+		return count > 0 ? true : false;
+	}
+	
+	@Override
+	public List<Company> list() {
+		// TODO Auto-generated method stub
+		return companyDAO.list();
+	}
+		
+	@Override
+	public Page<Company> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,boolean count,List<Sort> sortList) {
+        Page<Company> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
+            companyDAO.search(searchParams,sortList);
+        });
+        
+        return page;
+	}
+}

+ 96 - 0
common/src/main/resources/mapper/base/Company.xml

@@ -0,0 +1,96 @@
+<?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.CompanyDAO">
+	<resultMap id="CompanyMap" type="com.jpsoft.prices.modules.base.entity.Company">
+		<id property="id" column="id_" />
+			<result property="name" column="name_" />
+			<result property="remark" column="remark_" />
+			<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" />
+			</resultMap>
+	<insert id="insert" parameterType="com.jpsoft.prices.modules.base.entity.Company">
+	<!--
+	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
+		select sys_guid() from dual
+	</selectKey>
+	-->
+	<![CDATA[
+		insert into base_company
+	    (id_,name_,remark_,del_flag,create_time,create_by,update_time,update_by)
+		values
+		(
+#{id,jdbcType=VARCHAR}
+,#{name,jdbcType=VARCHAR}
+,#{remark,jdbcType=VARCHAR}
+,#{delFlag,jdbcType= NUMERIC }
+,#{createTime,jdbcType= TIMESTAMP }
+,#{createBy,jdbcType=VARCHAR}
+,#{updateTime,jdbcType= TIMESTAMP }
+,#{updateBy,jdbcType=VARCHAR}
+		)
+	]]>
+	</insert>
+	<delete id="delete" parameterType="string">
+		delete from base_company where id_=#{id,jdbcType=VARCHAR}
+	</delete>
+	<update id="update" parameterType="com.jpsoft.prices.modules.base.entity.Company">
+		update base_company
+		<set>
+				<if test="name!=null">
+		name_=#{name,jdbcType=VARCHAR},
+		</if>
+				<if test="remark!=null">
+		remark_=#{remark,jdbcType=VARCHAR},
+		</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="CompanyMap">
+		select id_,name_,remark_,del_flag,create_time,create_by,update_time,update_by from base_company where id_=#{0}
+	</select>
+	<select id="exist" parameterType="string" resultType="int">
+		select count(*) from base_company where id_=#{0}
+	</select>
+	<select id="list" resultMap="CompanyMap">
+		select * from base_company
+	</select>
+	<select id="search" parameterType="hashmap" resultMap="CompanyMap">
+		<![CDATA[
+			SELECT a.* FROM base_company a
+			LEFT JOIN base_company_destination b ON a.id_ = b.company_id
+		]]>
+		<where>
+			a.del_flag = 0
+			<if test="searchParams.name != null">
+				and a.name_ like #{searchParams.name}
+			</if>
+			<if test="searchParams.destinationId != null">
+				and b.destination_id like #{searchParams.destinationId}
+			</if>
+		</where>
+		GROUP BY a.id_
+		<foreach item="sort" collection="sortList"  open="order by" separator=",">
+	        ${sort.name} ${sort.order}
+	 	</foreach>
+	</select>
+</mapper>

+ 70 - 0
common/src/main/resources/mapper/base/CompanyDestination.xml

@@ -0,0 +1,70 @@
+<?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.CompanyDestinationDAO">
+	<resultMap id="CompanyDestinationMap" type="com.jpsoft.prices.modules.base.entity.CompanyDestination">
+		<id property="id" column="id_" />
+			<result property="companyId" column="company_id" />
+			<result property="destinationId" column="destination_id" />
+			</resultMap>
+	<insert id="insert" parameterType="com.jpsoft.prices.modules.base.entity.CompanyDestination">
+	<!--
+	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
+		select sys_guid() from dual
+	</selectKey>
+	-->
+	<![CDATA[
+		insert into base_company_destination
+	    (id_,company_id,destination_id)
+		values
+		(
+#{id,jdbcType=VARCHAR}
+,#{companyId,jdbcType=VARCHAR}
+,#{destinationId,jdbcType=VARCHAR}
+		)
+	]]>
+	</insert>
+	<delete id="delete" parameterType="string">
+		delete from base_company_destination where id_=#{id,jdbcType=VARCHAR}
+	</delete>
+	<update id="update" parameterType="com.jpsoft.prices.modules.base.entity.CompanyDestination">
+		update base_company_destination
+		<set>
+				<if test="companyId!=null">
+		company_id=#{companyId,jdbcType=VARCHAR},
+		</if>
+				<if test="destinationId!=null">
+		destination_id=#{destinationId,jdbcType=VARCHAR},
+		</if>
+		</set>
+	where id_=#{id}
+	</update>
+	<select id="get" parameterType="string" resultMap="CompanyDestinationMap">
+		select id_,company_id,destination_id from base_company_destination where id_=#{0}
+	</select>
+	<select id="exist" parameterType="string" resultType="int">
+		select count(*) from base_company_destination where id_=#{0}
+	</select>
+	<select id="list" resultMap="CompanyDestinationMap">
+		select * from base_company_destination
+	</select>
+	<select id="search" parameterType="hashmap" resultMap="CompanyDestinationMap">
+		<![CDATA[
+			select * from base_company_destination
+		]]>
+		<where>
+			<if test="searchParams.id != null">
+				and ID_ like #{searchParams.id}
+			</if>
+		</where>
+		<foreach item="sort" collection="sortList"  open="order by" separator=",">
+	        ${sort.name} ${sort.order}
+	 	</foreach>
+	</select>
+	<select id="findByCompany" parameterType="string" resultMap="CompanyDestinationMap">
+		select id_,company_id,destination_id from base_company_destination
+		where company_id=#{0}
+		order by destination_id asc
+	</select>
+</mapper>

+ 6 - 3
common/src/main/resources/mapper/base/Destination.xml

@@ -86,15 +86,18 @@ id_,parent_id,code_,name_,del_flag,create_time,create_by,update_time,update_by
 		]]>
 		<where>
 			del_flag = 0
-			<if test="searchParams.noCode">
+			<if test="searchParams.noCode != null">
 				and code_ NOT LIKE #{searchParams.noCode}
 			</if>
-			<if test="searchParams.name">
+			<if test="searchParams.name != null">
 				and name_ LIKE #{searchParams.name}
 			</if>
-			<if test="searchParams.parentId">
+			<if test="searchParams.parentId != null">
 				and parent_id = #{searchParams.parentId}
 			</if>
+			<if test="searchParams.noParent">
+				and parent_id IS NULL
+			</if>
 		</where>
 		<foreach item="sort" collection="sortList"  open="order by" separator=",">
 	        ${sort.name} ${sort.order}

+ 257 - 0
web/src/main/java/com/jpsoft/prices/modules/base/controller/CompanyController.java

@@ -0,0 +1,257 @@
+package com.jpsoft.prices.modules.base.controller;
+
+import com.github.pagehelper.Page;
+import com.jpsoft.prices.modules.base.entity.CompanyDestination;
+import com.jpsoft.prices.modules.base.entity.Destination;
+import com.jpsoft.prices.modules.base.service.CompanyDestinationService;
+import com.jpsoft.prices.modules.base.service.DestinationService;
+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.Company;
+import com.jpsoft.prices.modules.base.service.CompanyService;
+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.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+@RestController
+@RequestMapping("/base/company")
+@Api(description = "company")
+public class CompanyController {
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    @Autowired
+    private CompanyService companyService;
+    @Autowired
+    private DestinationService destinationService;
+    @Autowired
+    private CompanyDestinationService companyDestinationService;
+
+    @ApiOperation(value="创建空记录")
+    @GetMapping("create")
+    public MessageResult<Company> create(){
+        MessageResult<Company> msgResult = new MessageResult<>();
+
+        Company company = new Company();
+
+        msgResult.setData(company);
+        msgResult.setResult(true);
+
+        return msgResult;
+    }
+    
+    @ApiOperation(value="添加信息")
+    @PostMapping("add")
+    @Transactional(rollbackFor = Exception.class)
+    public MessageResult<Company> add(@RequestBody Company company,@RequestAttribute String subject){
+        MessageResult<Company> msgResult = new MessageResult<>();
+
+        try {
+            company.setId(UUID.randomUUID().toString());
+            company.setDelFlag(false);
+            company.setCreateBy(subject);
+            company.setCreateTime(new Date());
+            companyService.insert(company);
+
+            for(List list : company.getDestinationIds()){
+                CompanyDestination companyDestination = new CompanyDestination();
+                companyDestination.setId(UUID.randomUUID().toString());
+                companyDestination.setCompanyId(company.getId());
+                companyDestination.setDestinationId(StringUtils.join(list,","));
+                companyDestinationService.insert(companyDestination);
+            }
+
+            msgResult.setResult(true);
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="获取信息")
+    @GetMapping("edit/{id}")
+    public MessageResult<Company> edit(@PathVariable("id") String id){
+        MessageResult<Company> msgResult = new MessageResult<>();
+
+        try {
+            Company company = companyService.get(id);
+            List<List<String>> list = new ArrayList<>();
+            List<CompanyDestination> companyDestinationList = companyDestinationService.findByCompany(id);
+            for(CompanyDestination companyDestination : companyDestinationList){
+                List<String> strList = Arrays.asList(companyDestination.getDestinationId().split(","));
+                list.add(strList);
+            }
+            company.setDestinationIds(list);
+
+            msgResult.setResult(true);
+            msgResult.setData(company);
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="更新用户")
+    @PostMapping("update")
+    @Transactional(rollbackFor = Exception.class)
+    public MessageResult<Company> update(@RequestBody Company company,@RequestAttribute String subject){
+        MessageResult<Company> msgResult = new MessageResult<>();
+
+        try {
+            company.setUpdateBy(subject);
+            company.setUpdateTime(new Date());
+            companyService.update(company);
+
+            List<CompanyDestination> companyDestinationList = companyDestinationService.findByCompany(company.getId());
+            for(CompanyDestination companyDestination : companyDestinationList){
+                companyDestinationService.delete(companyDestination.getId());
+            }
+
+            for(List list : company.getDestinationIds()){
+                CompanyDestination companyDestination = new CompanyDestination();
+                companyDestination.setId(UUID.randomUUID().toString());
+                companyDestination.setCompanyId(company.getId());
+                companyDestination.setDestinationId(StringUtils.join(list,","));
+                companyDestinationService.insert(companyDestination);
+            }
+
+            msgResult.setResult(true);
+        }
+        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 {
+            Company company = companyService.get(id);
+            company.setDelFlag(true);
+            company.setUpdateBy(subject);
+            company.setUpdateTime(new Date());
+
+            int affectCount = companyService.update(company);
+
+            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) {
+                Company company = companyService.get(id);
+                company.setDelFlag(true);
+                company.setUpdateBy(subject);
+                company.setUpdateTime(new Date());
+
+                affectCount += companyService.update(company);
+            }
+
+            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 destinationId,
+            @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
+            @RequestParam(value="pageSize",defaultValue="20") int pageSize,
+            @RequestAttribute String subject){
+        MessageResult<Map> msgResult = new MessageResult<>();
+
+        Map<String,Object> searchParams = new HashMap<>();
+        if (StringUtils.isNotEmpty(name)) {
+            searchParams.put("name","%" + name + "%");
+        }
+        if (StringUtils.isNotEmpty(destinationId) && !"null".equals(destinationId)) {
+            searchParams.put("destinationId","%" + destinationId + "%");
+        }
+
+        List<Sort> sortList = new ArrayList<>();
+        sortList.add(new Sort("id_","asc"));
+
+        Page<Company> page = companyService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
+        for(Company company : page.getResult()){
+            List<String> nameList = new ArrayList<>();
+            List<CompanyDestination> companyDestinationList = companyDestinationService.findByCompany(company.getId());
+            for(CompanyDestination companyDestination : companyDestinationList){
+                List<String> names = new ArrayList<>();
+                String[] strIds = companyDestination.getDestinationId().split(",");
+                for(String strId : strIds) {
+                    Destination destination = destinationService.get(strId);
+                    names.add(destination.getName());
+                }
+                nameList.add(StringUtils.join(names," > "));
+            }
+            company.setDestinationNames(StringUtils.join(nameList,"<br/>"));
+        }
+
+        msgResult.setResult(true);
+        msgResult.setData(PojoUtils.pageWrapper(page));
+
+        return msgResult;
+    }
+}

+ 31 - 2
web/src/main/java/com/jpsoft/prices/modules/base/controller/DestinationController.java

@@ -262,7 +262,10 @@ public class DestinationController {
 
         list = destinationService.getListByParentId(parentId);
         for (Destination destination : list){
-            destination.setChildren(listByParentId(destination.getId()));
+            List<Destination> children = listByParentId(destination.getId());
+            if(children.size() > 0) {
+                destination.setChildren(children);
+            }
         }
 
         return list;
@@ -279,7 +282,7 @@ public class DestinationController {
         sortList.add(new Sort("parent_id", "asc"));
         sortList.add(new Sort("name_", "asc"));
 
-        if (StringUtils.isNotEmpty(code) && !"undefined".equals(code)) {
+        if (StringUtils.isNotEmpty(code)) {
             searchParams.put("noCode", code + "%");
         }
 
@@ -301,4 +304,30 @@ public class DestinationController {
 
         return StringUtils.join(names, " > ");
     }
+
+    @ApiOperation(value = "查询级联")
+    @RequestMapping(value = "queryCascader", method = RequestMethod.POST)
+    public MessageResult<List> queryCascader() {
+        MessageResult<List> msgResult = new MessageResult<>();
+
+        Map<String, Object> searchParams = new HashMap<>();
+        searchParams.put("noParent",true);
+
+        List<Sort> sortList = new ArrayList<>();
+        sortList.add(new Sort("parent_id", "asc"));
+        sortList.add(new Sort("name_", "asc"));
+
+        Page<Destination> page = destinationService.pageSearch(searchParams,1,10000,false,sortList);
+        for(Destination destination : page.getResult()){
+            List<Destination> children = listByParentId(destination.getId());
+            if(children.size() > 0) {
+                destination.setChildren(children);
+            }
+        }
+        List<Destination> destinationList = page.getResult();
+        msgResult.setResult(true);
+        msgResult.setData(destinationList);
+
+        return msgResult;
+    }
 }