diff --git a/bonus-api/bonus-api-system/src/main/java/com/bonus/base/api/domain/MaType.java b/bonus-api/bonus-api-system/src/main/java/com/bonus/base/api/domain/MaType.java index 985b5a7..6d5af26 100644 --- a/bonus-api/bonus-api-system/src/main/java/com/bonus/base/api/domain/MaType.java +++ b/bonus-api/bonus-api-system/src/main/java/com/bonus/base/api/domain/MaType.java @@ -21,6 +21,8 @@ import java.util.List; @NoArgsConstructor public class MaType extends BaseEntity implements Serializable { private static final long serialVersionUID = 135108051525707131L; + + private Integer isExport; /** * id */ @@ -51,21 +53,26 @@ public class MaType extends BaseEntity implements Serializable { /** * 库存 */ - private String storageNum; + private Integer storageNum; /** * 计量单位id */ private String unitId; + + /** + * 计量单位名称 + */ + private String unitName; /** * 采购单价 */ - private String buyPrice; + private Integer buyPrice; /** * 租赁单价 */ - private String leasePrice; + private Integer leasePrice; /** - * 管理类型0是编码1计数 + * 管理类型(0是编码 1数量和编码 2数量) */ private String manageType; /** @@ -81,7 +88,7 @@ public class MaType extends BaseEntity implements Serializable { */ private String testLoad; /** - * 持荷时间 + * 持荷时间 (分钟) */ private String holdTime; /** @@ -93,6 +100,11 @@ public class MaType extends BaseEntity implements Serializable { */ private String companyId; + /** + * 是否试验(0 否 1是) + */ + private String isTest; + /** 子节点 */ @JsonInclude(JsonInclude.Include.NON_EMPTY) private List children = new ArrayList<>(); diff --git a/bonus-api/bonus-api-system/src/main/java/com/bonus/system/api/RemoteDictService.java b/bonus-api/bonus-api-system/src/main/java/com/bonus/system/api/RemoteDictService.java index 4b9eb43..c5d80ef 100644 --- a/bonus-api/bonus-api-system/src/main/java/com/bonus/system/api/RemoteDictService.java +++ b/bonus-api/bonus-api-system/src/main/java/com/bonus/system/api/RemoteDictService.java @@ -42,20 +42,4 @@ public interface RemoteDictService { @GetMapping(value = "/dict/data/type/{dictType}") public R> getDictData(@RequestParam(value = "dictType", required = false) String dictType); - /** - * 往来单位树 - * @param sysDept - * @return - */ - @GetMapping("/customer/customerTree") - public R> selectCustomerTree(SysDeptTree sysDept); - - /** - * 工程树 - * @param sysDept - * @return - */ - @GetMapping("/customer/projectTree") - public R> selectProjectTree(SysDeptTree sysDept); - } diff --git a/bonus-api/bonus-api-system/src/main/java/com/bonus/system/api/factory/RemoteDictFallbackFactory.java b/bonus-api/bonus-api-system/src/main/java/com/bonus/system/api/factory/RemoteDictFallbackFactory.java index c001a8a..31afb9e 100644 --- a/bonus-api/bonus-api-system/src/main/java/com/bonus/system/api/factory/RemoteDictFallbackFactory.java +++ b/bonus-api/bonus-api-system/src/main/java/com/bonus/system/api/factory/RemoteDictFallbackFactory.java @@ -36,15 +36,6 @@ public class RemoteDictFallbackFactory implements FallbackFactory> selectCustomerTree(SysDeptTree sysDept) { - return R.fail("获取往来单位树数据失败" + throwable.getMessage()); - } - - @Override - public R> selectProjectTree(SysDeptTree sysDept) { - return R.fail("获取工程树数据失败" + throwable.getMessage()); - } }; } } diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/BaseTreeController.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/BaseTreeController.java index 7bd4a17..7e49746 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/BaseTreeController.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/BaseTreeController.java @@ -89,4 +89,13 @@ public class BaseTreeController { return AjaxResult.success(deptList); } + /** + * 获取计量单位 + */ + @RequestMapping("/getUnitName") + public R getUnitName(){ + R> bmProNature = remoteDictService.getDictData("ma_unit"); + return R.ok(bmProNature); + } + } diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/material/controller/MaTypeController.java b/bonus-modules/bonus-base/src/main/java/com/bonus/material/controller/MaTypeController.java index fab988f..2b893f0 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/material/controller/MaTypeController.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/material/controller/MaTypeController.java @@ -10,6 +10,7 @@ import com.bonus.material.service.MaTypeService; import com.bonus.material.vo.MaTypeVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -25,6 +26,7 @@ import java.util.List; @Api(tags = "机具类型管理") @RestController @RequestMapping("/maType") +@Slf4j public class MaTypeController extends BaseController { /** * 服务对象 @@ -60,6 +62,18 @@ public class MaTypeController extends BaseController { return success(getDataTable(listByMaType)); } + /** + * 根据id查询用于回显 + * @param id + * @return + */ + @ApiOperation(value = "根据id查询") + @GetMapping("/selectById") + public AjaxResult selectById(@RequestParam(value = "id") Integer id) { + MaType maType = maTypeService.selectById(id); + return success(maType); + } + /** * 新增数据返回code * @@ -124,6 +138,7 @@ public class MaTypeController extends BaseController { @PostMapping("/export") public void export(HttpServletResponse response, MaType maType) { + maType.setIsExport(1); List list = maTypeService.getListByParentId(maType); ExcelUtil util = new ExcelUtil<>(MaTypeVo.class); util.exportExcel(response, list, "物资类型数据"); diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/material/mapper/MaTypeMapper.java b/bonus-modules/bonus-base/src/main/java/com/bonus/material/mapper/MaTypeMapper.java index 54236ab..35b5a87 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/material/mapper/MaTypeMapper.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/material/mapper/MaTypeMapper.java @@ -2,7 +2,6 @@ package com.bonus.material.mapper; import com.bonus.base.api.domain.MaType; import com.bonus.material.vo.MaTypeVo; -import org.apache.ibatis.annotations.Param; import java.util.List; @@ -22,23 +21,6 @@ public interface MaTypeMapper { */ int insert(MaType maType); - /** - * 批量新增数据(MyBatis原生foreach方法) - * - * @param entities List 实例对象列表 - * @return 影响行数 - */ - int insertBatch(@Param("entities") List entities); - - /** - * 批量新增或按主键更新数据(MyBatis原生foreach方法) - * - * @param entities List 实例对象列表 - * @return 影响行数 - * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参 - */ - int insertOrUpdateBatch(@Param("entities") List entities); - /** * 修改数据 * @@ -100,5 +82,12 @@ public interface MaTypeMapper { * @return */ int deleteById(Integer id); + + /** + * 根据id查询 + * @param id + * @return + */ + MaType select(Integer id); } diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/material/service/MaTypeService.java b/bonus-modules/bonus-base/src/main/java/com/bonus/material/service/MaTypeService.java index c385bb6..e361961 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/material/service/MaTypeService.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/material/service/MaTypeService.java @@ -4,8 +4,6 @@ import com.bonus.base.api.domain.MaType; import com.bonus.base.api.domain.TreeSelect; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.material.vo.MaTypeVo; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; import java.util.List; @@ -66,4 +64,11 @@ public interface MaTypeService { * @return */ AjaxResult deleteById(Integer id); + + /** + * 根据id查询 + * @param id + * @return + */ + MaType selectById(Integer id); } diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/material/service/impl/MaTypeServiceImpl.java b/bonus-modules/bonus-base/src/main/java/com/bonus/material/service/impl/MaTypeServiceImpl.java index cbf22fb..44c0c66 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/material/service/impl/MaTypeServiceImpl.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/material/service/impl/MaTypeServiceImpl.java @@ -37,7 +37,7 @@ public class MaTypeServiceImpl implements MaTypeService { public AjaxResult insert(MaType maType) { //根据类型名称判断,去重 MaType type = maTypeDao.queryByName(maType.getName()); - if (type != null && maType.getId().equals(type.getParentId())) { + if (type != null && maType.getParentId().equals(type.getParentId())) { return AjaxResult.error("同级下类型名称存在重复!"); } maType.setLevel(String.valueOf(Integer.parseInt(maType.getLevel()) + 1)); @@ -58,8 +58,8 @@ public class MaTypeServiceImpl implements MaTypeService { public AjaxResult update(MaType maType) { //根据类型名称判断,去重 MaType type = maTypeDao.queryByName(maType.getName()); - if (type != null) { - return AjaxResult.error("类型名称重复"); + if (type != null && maType.getParentId().equals(type.getParentId())) { + return AjaxResult.error("同级下类型名称存在重复!"); } int result = maTypeDao.update(maType); if (result > 0) { @@ -87,7 +87,24 @@ public class MaTypeServiceImpl implements MaTypeService { */ @Override public List getListByParentId(MaType maType) { - return maTypeDao.getListByParentId(maType); + List maTypeVos = maTypeDao.getListByParentId(maType); + if (CollectionUtils.isNotEmpty(maTypeVos)) { + for (MaTypeVo maTypeVo : maTypeVos) { + if (maTypeVo.getIsTest() != null && "1".equals(maTypeVo.getIsTest())) { + maTypeVo.setIsTest("是"); + } else { + maTypeVo.setIsTest("否"); + } + if (maTypeVo.getManageType() != null && "0".equals(maTypeVo.getManageType())) { + maTypeVo.setManageType("编码追溯"); + } else if (maTypeVo.getManageType() != null && "1".equals(maTypeVo.getManageType())) { + maTypeVo.setManageType("数量+编码"); + } else { + maTypeVo.setManageType("数量"); + } + } + } + return maTypeVos; } /** @@ -190,6 +207,16 @@ public class MaTypeServiceImpl implements MaTypeService { return AjaxResult.error("删除失败"); } + /** + * 根据id查询 + * @param id + * @return + */ + @Override + public MaType selectById(Integer id) { + return maTypeDao.select(id); + } + /** * 构建前端所需要下拉树结构 * diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/material/vo/MaTypeVo.java b/bonus-modules/bonus-base/src/main/java/com/bonus/material/vo/MaTypeVo.java index cb14823..6365fea 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/material/vo/MaTypeVo.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/material/vo/MaTypeVo.java @@ -17,10 +17,6 @@ import lombok.NoArgsConstructor; @NoArgsConstructor public class MaTypeVo extends MaType { - @ApiModelProperty("类型编码") - @Excel(name = "类型编码") - private String code; - @ApiModelProperty("仓库信息") private String wareHouse ; @@ -40,6 +36,66 @@ public class MaTypeVo extends MaType { @Excel(name = "规格型号") private String specificationCode; + /** + * 层级 + */ + private String level; + + @ApiModelProperty("类型编码") + @Excel(name = "类型编码") + private String code; + + @ApiModelProperty("单位名称") + @Excel(name = "单位") + private String unitName; + + /** + * 管理类型(0是编码 1数量和编码 2数量) + */ + @Excel(name = "管理类型") + private String manageType; + + /** + * 库存 + */ + @Excel(name = "库存") + private Integer storageNum; + + /** + * 采购单价 + */ + @Excel(name = "购置价格") + private Integer buyPrice; + /** + * 租赁单价 + */ + @Excel(name = "租赁价格") + private Integer leasePrice; + + /** + * 持荷时间 (分钟) + */ + @Excel(name = "持荷时间 (分钟)") + private String holdTime; + + /** + * 是否试验(0 否 1是) + */ + @Excel(name = "是否试验") + private String isTest; + + /** + * 试验载荷 + */ + @Excel(name = "试验载荷") + private String testLoad; + + /** + * 额定载荷 + */ + @Excel(name = "额定载荷") + private String rateLoad; + @ApiModelProperty("新增类型编码") private String newCode; } diff --git a/bonus-modules/bonus-base/src/main/resources/mapper/material/MaTypeMapper.xml b/bonus-modules/bonus-base/src/main/resources/mapper/material/MaTypeMapper.xml index d032b6f..b7d8946 100644 --- a/bonus-modules/bonus-base/src/main/resources/mapper/material/MaTypeMapper.xml +++ b/bonus-modules/bonus-base/src/main/resources/mapper/material/MaTypeMapper.xml @@ -7,10 +7,10 @@ - + - - + + @@ -18,6 +18,7 @@ + @@ -47,9 +48,6 @@ manage_type = #{manageType}, - - is_active = #{isActive}, - rate_load = #{rateLoad}, @@ -65,8 +63,11 @@ company_id = #{companyId}, - where id = #{id} + + is_test = #{isTest} + + where id = #{id} update ma_type set is_active = '0' where id = #{id} @@ -91,28 +92,47 @@ ( SELECT mt.id, + f.`name` AS constructionType, + s.`name` AS materialType, + mtp.`name` AS materialName, mt.`name` AS specificationCode, mt.`level`, - mtp.`name` AS materialName, - s.`name` AS materialType, - f.`name` AS constructionType, - mt.`code`, + mt.`code` AS code, + sda.dict_label as unitName, + mt.manage_type as manageType, + mt.storage_num as storageNum, + mt.buy_price as buyPrice, + mt.lease_price as leasePrice, + mt.hold_time as hold_time, + mt.is_test as isTest, + mt.test_load as testLoad, + mt.rate_load as rateLoad, mt.is_active FROM ma_type mt LEFT JOIN ma_type mtp ON mtp.id = mt.parent_id LEFT JOIN ma_type s ON s.id = mtp.parent_id LEFT JOIN ma_type f ON f.id = s.parent_id + LEFT JOIN sys_dict_data sda on mt.unit_id = sda.dict_code WHERE mt.`LEVEL` = 4 UNION SELECT mt.id, + s.`name` AS constructionType, + mtp.`name` AS materialType, + mt.`name` AS materialName, NULL AS `NAME`, mt.`level`, - mt.`name` AS materialName, - mtp.`name` AS materialType, - s.`name` AS constructionType, mt.`CODE`, + mt.storage_num as storageNum, + mt.buy_price as buyPrice, + mt.lease_price as leasePrice, + mt.hold_time as hold_time, + mt.is_test as isTest, + mt.test_load as testLoad, + mt.rate_load as rateLoad, + NULL as unitName, + mt.manage_type as manageType, mt.is_active FROM ma_type mt @@ -122,13 +142,22 @@ mt.`LEVEL` = 3 UNION SELECT mt.id AS id, + mtp.`NAME` AS constructionType, + mt.`NAME` AS materialType, + NULL AS materialName, NULL AS `NAME`, mt.`level`, - NULL AS materialName, - mt.`NAME` AS materialType, - mtp.`NAME` AS constructionType, mt.`CODE`, - mt.IS_ACTIVE AS enabled + mt.storage_num as storageNum, + mt.buy_price as buyPrice, + mt.lease_price as leasePrice, + mt.hold_time as hold_time, + mt.is_test as isTest, + mt.test_load as testLoad, + mt.rate_load as rateLoad, + NULL as unitName, + mt.manage_type as manageType, + mt.IS_ACTIVE FROM ma_type mt LEFT JOIN ma_type mtp ON mtp.id = mt.PARENT_ID @@ -136,13 +165,22 @@ mt.`LEVEL` = 2 UNION SELECT mt.id AS id, + mt.`NAME` AS constructionType, + NULL AS materialType, + NULL AS materialName, NULL AS `NAME`, mt.`level`, - NULL AS materialName, - NULL AS materialType, - mt.`NAME` AS constructionType, mt.`CODE`, - mt.IS_ACTIVE AS enabled + mt.storage_num as storageNum, + mt.buy_price as buyPrice, + mt.lease_price as leasePrice, + mt.hold_time as hold_time, + mt.is_test as isTest, + mt.test_load as testLoad, + mt.rate_load as rateLoad, + NULL as unitName, + mt.manage_type as manageType, + mt.IS_ACTIVE FROM ma_type mt WHERE @@ -150,6 +188,9 @@ ) t WHERE t.IS_ACTIVE = '1' + + and t.`level`=4 + and ( t.specificationCode like CONCAT('%',#{keyWord},'%') or @@ -212,38 +253,14 @@ WHERE mt.is_active = '1' and mt.parent_id = #{id} + - - insert into ma_type(id, parent_id, name, level, storage_num, unit_id, buy_price, lease_price, manage_type, is_active, rate_load, test_load, hold_time, file_url, company_id) - values - - (#{entity.id}, #{entity.parentId}, #{entity.name}, #{entity.level}, #{entity.storageNum}, #{entity.unitId}, #{entity.buyPrice}, #{entity.leasePrice}, #{entity.manageType}, #{entity.isActive}, #{entity.rateLoad}, #{entity.testLoad}, #{entity.holdTime}, #{entity.fileUrl}, #{entity.companyId}) - - - - - insert into ma_type(id, parent_id, name, level, storage_num, unit_id, buy_price, lease_price, manage_type, is_active, rate_load, test_load, hold_time, file_url, company_id) - values - - (#{entity.id}, #{entity.parentId}, #{entity.name}, #{entity.level}, #{entity.storageNum}, #{entity.unitId}, #{entity.buyPrice}, #{entity.leasePrice}, #{entity.manageType}, #{entity.isActive}, #{entity.rateLoad}, #{entity.testLoad}, #{entity.holdTime}, #{entity.fileUrl}, #{entity.companyId}) - - on duplicate key update - id = values(id), - parent_id = values(parent_id), - name = values(name), - level = values(level), - storage_num = values(storage_num), - unit_id = values(unit_id), - buy_price = values(buy_price), - lease_price = values(lease_price), - manage_type = values(manage_type), - is_active = values(is_active), - rate_load = values(rate_load), - test_load = values(test_load), - hold_time = values(hold_time), - file_url = values(file_url), - company_id = values(company_id) - INSERT INTO ma_type @@ -262,6 +279,7 @@ hold_time, file_url, company_id, + is_test, VALUES @@ -280,6 +298,7 @@ #{holdTime}, #{fileUrl}, #{companyId}, + #{isTest},