wangqiang преди 2 години
родител
ревизия
06277d9a78
променени са 11 файла, в които са добавени 822 реда и са изтрити 4 реда
  1. 1 1
      jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/materialManagement/collect/mapper/xml/CollectDetailedMapper.xml
  2. 153 0
      jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/materialManagement/materialType/controller/MaterialTypeController.java
  3. 88 0
      jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/materialManagement/materialType/domain/MaterialTypeInfo.java
  4. 70 0
      jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/materialManagement/materialType/mapper/MaterialTypeMapper.java
  5. 106 0
      jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/materialManagement/materialType/mapper/xml/MaterialTypeMapper.xml
  6. 178 0
      jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/materialManagement/materialType/service/MaterialTypeForTreeDataService.java
  7. 202 0
      jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/materialManagement/materialType/service/MaterialTypeService.java
  8. 21 0
      jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/materialManagement/materialType/service/dto/MaterialTypeDto.java
  9. 1 1
      jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/materialManagement/purchase/mapper/xml/MaterialDetailedMapper.xml
  10. 1 1
      jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/materialManagement/wareHouse/mapper/xml/WareHouseBasicMapper.xml
  11. 1 1
      jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/materialManagement/wareHouse/mapper/xml/WareHouseDetailedMapper.xml

+ 1 - 1
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/materialManagement/collect/mapper/xml/CollectDetailedMapper.xml

@@ -7,7 +7,7 @@
         from material_management_collect_detailed a
         left join sys_user su on a.recipient_agent = su.id
         left join sys_office so on su.office_id = so.id
-        left join cw_reimbursement_type_info d on a.collect_type = d.id
+        left join material_management_type d on a.collect_type = d.id
         where a.basic_id = #{basicId} and a.del_flag = '0'
     </select>
     <select id="getByAttachmentId" resultType="com.jeeplus.test.workContract.service.dto.WorkAttachmentDto">

+ 153 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/materialManagement/materialType/controller/MaterialTypeController.java

@@ -0,0 +1,153 @@
+package com.jeeplus.test.materialManagement.materialType.controller;
+
+import com.jeeplus.test.materialManagement.materialType.domain.MaterialTypeInfo;
+import com.jeeplus.test.materialManagement.materialType.mapper.MaterialTypeMapper;
+import com.jeeplus.test.materialManagement.materialType.service.MaterialTypeForTreeDataService;
+import com.jeeplus.test.materialManagement.materialType.service.MaterialTypeService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * @author: 王强
+ * @create: 2022-11-25 09:18
+ **/
+@RestController
+@Api(tags ="财务-报销类型管理")
+@RequestMapping(value = "/material/materialType")
+public class MaterialTypeController {
+
+    @Resource
+    private MaterialTypeService service;
+
+    @Resource
+    private MaterialTypeForTreeDataService treeService;
+
+    @Resource
+    private MaterialTypeMapper mapper;
+
+    /**
+     * 列表查询
+     * @param info
+     * @return
+     */
+    @ApiOperation(value = "列表查询")
+    @GetMapping("/list")
+    public ResponseEntity<List<MaterialTypeInfo>> list(MaterialTypeInfo info) {
+        List<MaterialTypeInfo> list = service.list(info);
+        return ResponseEntity.ok(list);
+    }
+
+    /**
+     * 列表查询
+     * @param info
+     * @return
+     */
+    @ApiOperation(value = "列表查询")
+    @GetMapping("/bxList")
+    public ResponseEntity<List<MaterialTypeInfo>> bxList(MaterialTypeInfo info) {
+        List<MaterialTypeInfo> list = service.bxList(info);
+        return ResponseEntity.ok(list);
+    }
+
+    /**
+     * 采购类型列表查询
+     * @param info
+     * @return
+     */
+    @ApiOperation(value = "采购类型列表查询")
+    @GetMapping("/cgList")
+    public ResponseEntity<List<MaterialTypeInfo>> cgList(MaterialTypeInfo info) {
+        List<MaterialTypeInfo> list = service.cgList(info);
+        return ResponseEntity.ok(list);
+    }
+
+    /**
+     * 新增/修改
+     * @param info
+     * @return
+     */
+    @ApiOperation(value = "新增/修改")
+    @PostMapping("/save")
+    public ResponseEntity<String> save(@RequestBody MaterialTypeInfo info) {
+        String s = service.save(info);
+        return ResponseEntity.ok(s);
+    }
+
+    /**
+     * 根据id查询
+     * @param id
+     * @return
+     */
+    @ApiOperation(value = "根据id查询")
+    @GetMapping("/findById")
+    public ResponseEntity<MaterialTypeInfo> findById(String id) {
+        MaterialTypeInfo info = service.getById(id);
+        return ResponseEntity.ok(info);
+    }
+
+    /**
+     * 根据id删除
+     * @param id
+     * @return
+     */
+    @ApiOperation(value = "根据id删除")
+    @GetMapping("/deleteById")
+    public ResponseEntity<String> deleteById(String id) {
+        String s = service.remove(id);
+        return ResponseEntity.ok(s);
+    }
+
+    /**
+     * 查询树形
+     * @param extId 排除的ID
+     * @return
+     */
+    @ApiOperation(value = "查询树形")
+    @GetMapping("/treeData")
+    public ResponseEntity<List<MaterialTypeInfo>> treeData(@RequestParam(required = false) String extId, @RequestParam(required = false) String type) throws Exception{
+        List<MaterialTypeInfo> infos = treeService.treeDataForType(extId, type);
+        return ResponseEntity.ok(infos);
+    }
+
+    /**
+     * 查询树形
+     * @param extId 排除的ID
+     * @return
+     */
+    @ApiOperation(value = "查询树形")
+    @GetMapping("/treeData1")
+    public ResponseEntity<List<MaterialTypeInfo>> treeData1(@RequestParam(required = false) String extId, @RequestParam(required = false) String type) throws Exception{
+        List<MaterialTypeInfo> infos = treeService.treeDataForType1(extId, type);
+        return ResponseEntity.ok(infos);
+    }
+
+    /**
+     * 查询树形
+     * @param extId 排除的ID
+     * @return
+     */
+    @ApiOperation(value = "查询树形")
+    @GetMapping("/summaryTreeData")
+    public ResponseEntity<List<MaterialTypeInfo>> summaryTreeData(@RequestParam(required = false) String extId, @RequestParam(required = false) String type) throws Exception{
+        List<MaterialTypeInfo> infos = treeService.summaryTreeData(extId, type);
+        return ResponseEntity.ok(infos);
+    }
+
+    /**
+     * 查询树形
+     * @param extId 排除的ID
+     * @return
+     */
+    @ApiOperation(value = "查询树形")
+    @GetMapping("/treeData2")
+    public ResponseEntity<List<MaterialTypeInfo>> treeData2(@RequestParam(required = false) String extId, @RequestParam(required = false) String type) throws Exception{
+        List<MaterialTypeInfo> infos = treeService.treeDataForType2(extId, type);
+        return ResponseEntity.ok(infos);
+    }
+
+}

+ 88 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/materialManagement/materialType/domain/MaterialTypeInfo.java

@@ -0,0 +1,88 @@
+package com.jeeplus.test.materialManagement.materialType.domain;
+
+import com.baomidou.mybatisplus.annotation.*;
+import com.jeeplus.core.domain.TreeEntity;
+import com.jeeplus.core.query.Query;
+import com.jeeplus.sys.service.dto.OfficeDTO;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 物资类型信息列表
+ * @author: 王强
+ * @create: 2022-11-25 08:59
+ **/
+@Data
+@TableName(value = "material_management_type")
+public class MaterialTypeInfo extends TreeEntity<MaterialTypeInfo> {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 实体主键
+     */
+    @TableId
+    private String id;
+
+    /**
+     * 创建日期
+     */
+    @TableField(fill = FieldFill.INSERT)
+    private Date createDate;
+
+    /**
+     * 创建人
+     */
+    @Query
+    @TableField(fill = FieldFill.INSERT)
+    private String createBy;
+
+    /**
+     * 更新日期
+     */
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    private Date updateDate;
+
+    /**
+     * 更新人
+     */
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    private String updateBy;
+
+    /**
+     * 逻辑删除标记
+     */
+    @TableLogic
+    @TableField(fill = FieldFill.INSERT)
+    private Integer delFlag;
+
+    /**
+     * 层级
+     */
+    private String level;
+
+    /**
+     * 报销类型名称
+     */
+    @Query
+    private String name;
+
+    /**
+     * 序号
+     */
+    @Query
+    private Integer sort;
+
+    /**
+     * 父节点id
+     */
+    private String parentId;
+
+    private String parentIds;
+
+    @TableField(exist = false)
+    private Boolean disabled = false;
+
+}

+ 70 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/materialManagement/materialType/mapper/MaterialTypeMapper.java

@@ -0,0 +1,70 @@
+package com.jeeplus.test.materialManagement.materialType.mapper;
+
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.toolkit.Constants;
+import com.jeeplus.core.domain.TreeMapper;
+import com.jeeplus.test.materialManagement.materialType.domain.MaterialTypeInfo;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * @author: 王强
+ * @create: 2022-11-25 09:02
+ **/
+public interface MaterialTypeMapper extends BaseMapper<MaterialTypeInfo>, TreeMapper<MaterialTypeInfo> {
+
+    /**
+     * 查询数据集合
+     * @param queryWrapper
+     * @return
+     */
+    List<MaterialTypeInfo> findList(@Param(Constants.WRAPPER) Wrapper<MaterialTypeInfo> queryWrapper);
+
+
+    /**
+     * 根据id查询详情信息
+     * @param id
+     * @return
+     */
+    MaterialTypeInfo getById(String id);
+    /**
+     * 根据name和parentId查询名称是否重复
+     * @param name
+     * @param parentId
+     * @return
+     */
+    Integer checkNameIsExist(@Param("name") String name, @Param("parentId") String parentId);
+
+    Integer getNo(@Param("parentId") String parentId);
+
+    Integer getLevel(@Param("parentId") String parentId);
+
+    List<String> getChildId(String id);
+
+    /**
+     * 获取所有业务类型的数据
+     * @return
+     */
+    List<MaterialTypeInfo> getAllList();
+
+    /**
+     * 删除报销类型关联表对应信息
+     * @param id
+     */
+    void deleteReimbursementTypeOfficeInfo(String id);
+
+    /**
+     * 删除三级层级
+     * @param id
+     */
+    void deleteLevel3(String id);
+
+    /**
+     * 删除二级层级
+     * @param id
+     */
+    void deleteLevel2(String id);
+
+}

+ 106 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/materialManagement/materialType/mapper/xml/MaterialTypeMapper.xml

@@ -0,0 +1,106 @@
+<?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">
+<mapper namespace="com.jeeplus.test.materialManagement.materialType.mapper.MaterialTypeMapper">
+	<resultMap id="BaseResultMap" type="com.jeeplus.test.materialManagement.materialType.domain.MaterialTypeInfo">
+		<id property="id" column="id" jdbcType="VARCHAR"/>
+		<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
+		<result property="createDate" column="create_date" jdbcType="TIMESTAMP"/>
+		<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
+		<result property="updateDate" column="update_date" jdbcType="TIMESTAMP"/>
+		<result property="delFlag" column="del_flag" jdbcType="INTEGER"/>
+
+		<result property="level" column="level" jdbcType="VARCHAR"/>
+		<result property="name" column="name" jdbcType="VARCHAR"/>
+		<result property="sort" column="sort" jdbcType="VARCHAR"/>
+		<result property="parentId" column="parent_id" jdbcType="VARCHAR"/>
+		<result property="parentIds" column="parent_ids" jdbcType="VARCHAR"/>
+
+	</resultMap>
+
+
+	<sql id="Base_Column_List">
+        a.id,
+        a.create_by,
+        a.create_date,
+        a.update_by,
+        a.update_date,
+        a.del_flag,
+        a.level,
+		a.name,
+		a.sort,
+		a.parent_id,
+		a.parent_ids
+    </sql>
+
+
+	<select id="findList" resultMap="BaseResultMap">
+		select
+		<include refid="Base_Column_List"></include>
+		from material_management_type a
+		${ew.customSqlSegment}
+	</select>
+
+
+	<select id="getById" resultMap="BaseResultMap">
+		select
+		<include refid="Base_Column_List"></include>
+		from material_management_type a
+		<where>
+			a.del_flag = 0 and a.id = #{id}
+		</where>
+	</select>
+
+	<select id="checkNameIsExist" resultType="java.lang.Integer">
+        SELECT
+			COUNT( 0 )
+		FROM
+			material_management_type
+		WHERE
+			del_flag = 0
+			AND `name` = #{name}
+			AND parent_id = #{parentId}
+    </select>
+    <select id="getNo" resultType="java.lang.Integer">
+        SELECT
+			(MAX(`sort`) + 1) AS `sort`
+		FROM
+			material_management_type
+		WHERE
+			del_flag = 0
+			AND parent_id = #{parentId}
+    </select>
+    <select id="getLevel" resultType="java.lang.Integer">
+        SELECT
+			(MAX(level) + 1) AS `level`
+		FROM
+			material_management_type
+		WHERE
+			del_flag = 0
+			AND id = #{parentId}
+    </select>
+	<select id="getChildId" resultType="java.lang.String">
+		select id from material_management_type where parent_id = #{id}
+	</select>
+	<select id="getAllList"
+			resultType="com.jeeplus.test.materialManagement.materialType.domain.MaterialTypeInfo">
+		select * from material_management_type where  del_flag = '0' order by sort asc
+	</select>
+
+	<delete id="deleteReimbursementTypeOfficeInfo">
+		delete from material_management_type where reimbursement_type_id = #{id}
+	</delete>
+	<delete id="deleteLevel3">
+		UPDATE material_management_type set del_flag = 1 WHERE id in (
+		SELECT a.id FROM
+		( SELECT id FROM material_management_type WHERE parent_id in
+		(SELECT id FROM material_management_type WHERE parent_id = #{id}
+		)) a)
+	</delete>
+	<delete id="deleteLevel2">
+		UPDATE material_management_type set del_flag = 1 WHERE id in (
+		SELECT a.id FROM
+		(SELECT id FROM material_management_type WHERE parent_id = #{id}
+		) a)
+	</delete>
+
+</mapper>

+ 178 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/materialManagement/materialType/service/MaterialTypeForTreeDataService.java

@@ -0,0 +1,178 @@
+package com.jeeplus.test.materialManagement.materialType.service;
+
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.jeeplus.core.service.TreeService;
+import com.jeeplus.core.service.dto.TreeDTO;
+import com.jeeplus.test.materialManagement.materialType.domain.MaterialTypeInfo;
+import com.jeeplus.test.materialManagement.materialType.mapper.MaterialTypeMapper;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author: 王强
+ * @create: 2022-11-25 09:01
+ **/
+@Service
+public class MaterialTypeForTreeDataService extends TreeService<MaterialTypeMapper, MaterialTypeInfo> {
+
+    @Resource
+    private MaterialTypeMapper typeMapper;
+
+    /**
+     * 获取JSON树形数据。
+     *
+     * @param extId 排除的ID
+     * @param type 禁选类型
+     * @return
+     */
+    public List<MaterialTypeInfo> treeDataForType(String extId, String type) throws Exception{
+        //获取所有的业务类型为1的数据
+//        List<CwReimbursementTypeInfo> allList = typeMapper.getAllList("1");
+        List<MaterialTypeInfo> allList = typeMapper.findList (new LambdaQueryWrapper<>( (Class <MaterialTypeInfo>) entityClass ).orderByAsc ( MaterialTypeInfo::getSort ));
+        MaterialTypeInfo root = entityClass.getConstructor ( ).newInstance ( );
+        root.setId ( TreeDTO.getRootId () );
+        List <MaterialTypeInfo> rootTree = this.formatListToTreeForType ( root, allList, extId, type );
+        return rootTree;
+    }
+
+    /**
+     * 获取JSON树形数据。
+     *
+     * @param extId 排除的ID
+     * @param type 禁选类型
+     * @return
+     */
+    public List<MaterialTypeInfo> treeDataForType1(String extId, String type) throws Exception{
+        //获取所有的业务类型为1的数据
+        List<MaterialTypeInfo> allList = typeMapper.getAllList();
+//        List<CwReimbursementTypeInfo> allList = super.list (new LambdaQueryWrapper<>( (Class <CwReimbursementTypeInfo>) entityClass ).orderByAsc ( CwReimbursementTypeInfo::getSort ));
+        MaterialTypeInfo root = entityClass.getConstructor ( ).newInstance ( );
+        root.setId ( TreeDTO.getRootId () );
+        List <MaterialTypeInfo> rootTree = this.formatListToTreeForType ( root, allList, extId, type );
+        return rootTree;
+    }
+
+    /**
+     * 获取JSON树形数据。
+     *
+     * @param extId 排除的ID
+     * @param type 禁选类型
+     * @return
+     */
+    public List<MaterialTypeInfo> summaryTreeData(String extId, String type) throws Exception{
+        //获取所有的业务类型为1的数据
+        List<MaterialTypeInfo> allList = typeMapper.getAllList();
+        MaterialTypeInfo root = entityClass.getConstructor ( ).newInstance ( );
+        root.setId ( TreeDTO.getRootId () );
+        List <MaterialTypeInfo> rootTree = this.formatListToTreeForType ( root, allList, extId, type );
+        return rootTree;
+    }
+
+    /**
+     * 获取JSON树形数据。
+     *
+     * @param extId 排除的ID
+     * @param type 禁选类型
+     * @return
+     */
+    public List<MaterialTypeInfo> treeDataForType2(String extId, String type) throws Exception{
+        //获取所有的业务类型为1的数据
+        List<MaterialTypeInfo> allList = typeMapper.getAllList();
+//        List<CwReimbursementTypeInfo> allList = super.list (new LambdaQueryWrapper<>( (Class <CwReimbursementTypeInfo>) entityClass ).orderByAsc ( CwReimbursementTypeInfo::getSort ));
+        MaterialTypeInfo root = entityClass.getConstructor ( ).newInstance ( );
+        root.setId ( TreeDTO.getRootId () );
+        List <MaterialTypeInfo> rootTree = this.formatListToTreeForType ( root, allList, extId, type );
+        return rootTree;
+    }
+
+    /**
+     * 以root为根节点, 将allList从线性列表转为树形列表
+     *
+     * @param root    根节点, 为空抛出空指针异常
+     * @param allList 所有需要参与构造为树的列表
+     * @param extId   需要排除在树之外的节点(子节点一并被排除)
+     * @return java.util.List<T>
+     * @Author 滕鑫源
+     * @Date 2020/10/23 17:04
+     **/
+    public List <MaterialTypeInfo> formatListToTreeForType (MaterialTypeInfo root, List <MaterialTypeInfo> allList, String extId, String type) {
+        String rootId = root.getId ( );
+        // 最终的树形态
+        List <MaterialTypeInfo> trees = Lists.newArrayList ( );
+
+        // 把需要构造树的所有列表, 根据以父id作为key, 整理为列表
+        Map<String, List <MaterialTypeInfo>> treeMap = Maps.newHashMap ( );
+        for (MaterialTypeInfo entity : allList) {
+            List <MaterialTypeInfo> entities = treeMap.get ( entity.getParentId ( ) );
+            if ( entities == null ) {
+                entities = Lists.newLinkedList ( );
+            }
+
+            // 剔除排除项, 构造treeMap, 转递归为线性操作
+            if ( StrUtil.isBlank ( extId ) || (!extId.equals ( entity.getId ( ) ) && entity.getParentIds ( ).indexOf ( "," + extId + "," ) == -1) ) {
+                entities.add ( entity );
+                treeMap.put ( entity.getParentId ( ), entities );
+            }
+
+            if (StringUtils.isNotEmpty(type)) {
+                //禁选类型设置disable值为true
+                if ("last".equals(type)) {
+                    allList.stream().forEach(item -> {
+                        if (StringUtils.isNotBlank(item.getParentId())) {
+                            if (item.getParentId().equals(entity.getId())) {
+                                entity.setDisabled(true);
+                            }
+                        }
+                    });
+                } else {
+                    if (type.contains(entity.getLevel())) {
+                        entity.setDisabled(true);
+                    }
+                }
+            }
+        }
+
+        // 没有给定的子树, 返回空树
+        if ( treeMap.get ( rootId ) == null || treeMap.get ( rootId ).isEmpty ( ) ) {
+            return trees;
+        }
+
+        // 开始递归格式化
+        List <MaterialTypeInfo> children = treeMap.get ( rootId );
+        for (MaterialTypeInfo parent : children) {
+            formatFillChildren ( parent, treeMap );
+            trees.add ( parent );
+        }
+        if ( StrUtil.equals ( rootId, TreeDTO.getRootId () ) ) {
+            return children;
+        } else {
+            root.setChildren ( trees );
+            return Lists.newArrayList ( root );
+        }
+    }
+    /**
+     * 从treeMap中取出子节点填入parent, 并递归此操作
+     *
+     * @param parent
+     * @param treeMap
+     * @return void
+     * @Author 滕鑫源
+     * @Date 2020/9/30 16:33
+     **/
+    private void formatFillChildren(MaterialTypeInfo parent, Map <String, List <MaterialTypeInfo>> treeMap) {
+        List <MaterialTypeInfo> children = treeMap.get ( parent.getId ( ) );
+        parent.setChildren ( children );
+        if ( children != null && !children.isEmpty ( ) ) {
+            for (MaterialTypeInfo child : children) {
+                formatFillChildren ( child, treeMap );
+            }
+        }
+    }
+}

+ 202 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/materialManagement/materialType/service/MaterialTypeService.java

@@ -0,0 +1,202 @@
+package com.jeeplus.test.materialManagement.materialType.service;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.jeeplus.core.domain.BaseEntity;
+import com.jeeplus.sys.service.dto.OfficeDTO;
+import com.jeeplus.sys.service.dto.UserDTO;
+import com.jeeplus.sys.utils.StringUtils;
+import com.jeeplus.sys.utils.UserUtils;
+import com.jeeplus.test.materialManagement.materialType.domain.MaterialTypeInfo;
+import com.jeeplus.test.materialManagement.materialType.mapper.MaterialTypeMapper;
+import org.apache.commons.compress.utils.Lists;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * @author: 王强
+ * @create: 2022-11-25 09:13
+ **/
+@Service
+public class MaterialTypeService {
+
+    @Resource
+    private MaterialTypeMapper mapper;
+
+    public List<MaterialTypeInfo> list(MaterialTypeInfo info) {
+        LambdaQueryWrapper<MaterialTypeInfo> wrapper = new LambdaQueryWrapper<>();
+        if (StringUtils.isNotEmpty(info.getName())) {
+            wrapper.like(MaterialTypeInfo::getName, info.getName());
+        }
+        if (info.getSort() != null) {
+            wrapper.like(MaterialTypeInfo::getSort, info.getSort());
+        }
+//        wrapper.eq(CwReimbursementTypeInfo::getBusinessType, "1");
+
+        wrapper.eq(BaseEntity::getDelFlag, 0);
+        wrapper.orderByAsc(MaterialTypeInfo::getSort);
+        return mapper.findList(wrapper);
+    }
+
+
+    /**
+     * 根据id查询项目详情
+     * @param id
+     * @return
+     */
+    public MaterialTypeInfo getById(String id) {
+        MaterialTypeInfo info = mapper.getById(id);
+        return info;
+    }
+
+    public List<MaterialTypeInfo> bxList(MaterialTypeInfo info) {
+        LambdaQueryWrapper<MaterialTypeInfo> wrapper = new LambdaQueryWrapper<>();
+        if (StringUtils.isNotEmpty(info.getName())) {
+            wrapper.like(MaterialTypeInfo::getName, info.getName());
+        }
+        if (info.getSort() != null) {
+            wrapper.like(MaterialTypeInfo::getSort, info.getSort());
+        }
+
+        wrapper.eq(BaseEntity::getDelFlag, 0);
+        wrapper.orderByAsc(MaterialTypeInfo::getSort);
+        return mapper.selectList(wrapper);
+    }
+
+    public List<MaterialTypeInfo> cgList(MaterialTypeInfo info) {
+        LambdaQueryWrapper<MaterialTypeInfo> wrapper = new LambdaQueryWrapper<>();
+        if (StringUtils.isNotEmpty(info.getName())) {
+            wrapper.like(MaterialTypeInfo::getName, info.getName());
+        }
+        if (info.getSort() != null) {
+            wrapper.like(MaterialTypeInfo::getSort, info.getSort());
+        }
+
+        wrapper.eq(BaseEntity::getDelFlag, 0);
+        wrapper.orderByAsc(MaterialTypeInfo::getSort);
+        return mapper.selectList(wrapper);
+    }
+
+    public String save(MaterialTypeInfo info) {
+        // parentId未传值,则表示一级菜单
+        if(StringUtils.isEmpty(info.getParentId())) {
+            info.setParentId("0");
+        }
+        // 保存数据
+        if (StringUtils.isNotEmpty(info.getId())) {
+            return update(info);
+        }
+        return add(info);
+    }
+
+    /**
+     * 新增
+     * @param info
+     * @return
+     */
+    public String add(MaterialTypeInfo info) {
+        // 判断名称是否已存在
+        Integer isExist = mapper.checkNameIsExist(info.getName(), info.getParentId());
+        if (isExist > 0) {
+            return "false";
+        }
+        // 获取当前登录人信息
+        UserDTO userDto = UserUtils.getCurrentUserDTO();
+        // 生成id值
+        String id = UUID.randomUUID().toString().replace("-", "");
+        info.setId(id);
+        info.setCreateBy(userDto.getId());
+        info.setCreateDate(new Date());
+        info.setUpdateBy(userDto.getId());
+        info.setUpdateDate(new Date());
+        info.setDelFlag(0);
+        // 生成序号/层级
+        getNo(info);
+        mapper.insert(info);
+        return "操作完成";
+    }
+
+    /**
+     * 修改
+     * @param info
+     * @return
+     */
+    public String update(MaterialTypeInfo info) {
+        // 获取当前登录人信息
+        UserDTO userDto = UserUtils.getCurrentUserDTO();
+        info.setUpdateBy(userDto.getId());
+        info.setUpdateDate(new Date());
+        mapper.updateById(info);
+        return "操作完成";
+    }
+
+    /**
+     * 生成序号/层级
+     * @param info
+     * @return
+     */
+    public MaterialTypeInfo getNo(MaterialTypeInfo info) {
+        MaterialTypeInfo parentInfo = null;
+        if (!"0".equals(info.getParentId())) {
+            //根据parentId查询父节点信息
+            LambdaQueryWrapper<MaterialTypeInfo> wrapper = new LambdaQueryWrapper<>();
+            wrapper.eq(BaseEntity::getDelFlag, 0);
+            wrapper.eq(BaseEntity::getId, info.getParentId());
+            parentInfo = mapper.selectOne(wrapper);
+        }
+        //查询序号
+        Integer no = mapper.getNo(info.getParentId());
+        // 该层级下有数据,正常返回序号值
+        if (no != null) {
+            info.setSort(no);
+        } else {
+            // 父节点存在,根据父节点序号生成;不存在,则表示无上级层级,从1开始
+            if (parentInfo != null) {
+                String s = parentInfo.getSort() + "01";
+                info.setSort(Integer.parseInt(s));
+            } else {
+                info.setSort(1);
+            }
+        }
+        // 生成层级
+        //查询层级
+        Integer level = mapper.getLevel(info.getParentId());
+        if (level != null) {
+            info.setLevel(level.toString());
+        } else {
+            // 父节点存在,根据父节点level生成,不存在,则表示无上级层级,从1开始
+            if (parentInfo != null) {
+                Integer i = Integer.parseInt(parentInfo.getLevel())+1;
+                info.setLevel(i.toString());
+            } else {
+                info.setLevel("1");
+            }
+        }
+        return info;
+    }
+
+    public String remove(String id) {
+        //如果层级是一级或者是二级,则应该将一级下的所有信息删除或二级下的所有信息删除,反之为三级则直接删除
+        MaterialTypeInfo typeInfo = mapper.getById(id);
+        if (typeInfo.getLevel().equals("1")){
+            //三个层级的情况
+            mapper.deleteLevel3(id);
+            //删除二级的信息
+            mapper.deleteLevel2(id);
+            //删除一级的信息
+            mapper.deleteById(id);
+        } else if (typeInfo.getLevel().equals("2")) {
+            //两个层级的情况
+            mapper.deleteLevel2(id);
+            //删除二级的信息
+            mapper.deleteById(id);
+        } else if (typeInfo.getLevel().equals("3")) {
+            mapper.deleteById(id);
+        }
+        return "操作成功";
+    }
+}

+ 21 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/materialManagement/materialType/service/dto/MaterialTypeDto.java

@@ -0,0 +1,21 @@
+package com.jeeplus.test.materialManagement.materialType.service.dto;
+
+import com.jeeplus.core.domain.BaseEntity;
+import lombok.Data;
+
+/**
+ * @author: 王强
+ * @create: 2022-11-25 09:04
+ **/
+@Data
+public class MaterialTypeDto extends BaseEntity {
+
+    private String level;
+
+    private String name;
+
+    private Integer sort;
+
+    private String parentId;
+
+}

+ 1 - 1
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/materialManagement/purchase/mapper/xml/MaterialDetailedMapper.xml

@@ -7,7 +7,7 @@
         from material_management_pruchase_request_detailed a
         left join sys_user su on a.purchaser_agent = su.id
         left join sys_office so on su.office_id = so.id
-        left join cw_reimbursement_type_info d on a.procurement_type = d.id
+        left join material_management_type d on a.procurement_type = d.id
         where a.basic_id = #{basicId} and a.del_flag = '0'
     </select>
     <select id="getByAttachmentId" resultType="com.jeeplus.test.workContract.service.dto.WorkAttachmentDto">

+ 1 - 1
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/materialManagement/wareHouse/mapper/xml/WareHouseBasicMapper.xml

@@ -48,7 +48,7 @@
 			left join material_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0 GROUP BY e.goods_name) b
 			on a.trade_name = b.goods_name and b.status = 5
 
-			left join cw_reimbursement_type_info c on a.ware_house_type = c.id
+			left join material_management_type c on a.ware_house_type = c.id
 			${ew.customSqlSegment}
 			GROUP BY a.trade_name
 			ORDER BY a.update_date DESC

+ 1 - 1
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/materialManagement/wareHouse/mapper/xml/WareHouseDetailedMapper.xml

@@ -8,7 +8,7 @@
         from material_management_warehouse_detailed a
         left join sys_user b on a.ware_house_man = b.id and b.del_flag = '0'
         left join sys_office c on b.office_id = c.id
-        left join cw_reimbursement_type_info d on a.ware_house_type = d.id
+        left join material_management_type d on a.ware_house_type = d.id
         where a.basic_id = #{id} and a.del_flag = '0'
         ORDER BY a.create_date desc
     </select>