diff --git a/jshERP-boot/docs/jsh_erp.sql b/jshERP-boot/docs/jsh_erp.sql index 9cef8f183..5f8719c31 100644 --- a/jshERP-boot/docs/jsh_erp.sql +++ b/jshERP-boot/docs/jsh_erp.sql @@ -540,6 +540,7 @@ CREATE TABLE `jsh_material_property` ( `enabled` bit(1) DEFAULT NULL COMMENT '是否启用', `sort` varchar(10) DEFAULT NULL COMMENT '排序', `another_name` varchar(50) DEFAULT NULL COMMENT '别名', + `tenant_id` bigint(20) DEFAULT NULL COMMENT '租户id', `delete_flag` varchar(1) DEFAULT '0' COMMENT '删除标记,0未删除,1删除', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COMMENT='产品扩展字段表'; @@ -547,10 +548,6 @@ CREATE TABLE `jsh_material_property` ( -- ---------------------------- -- Records of jsh_material_property -- ---------------------------- -INSERT INTO `jsh_material_property` VALUES ('1', '制造商', '', '01', '制造商', '0'); -INSERT INTO `jsh_material_property` VALUES ('2', '自定义1', '', '02', '自定义1', '0'); -INSERT INTO `jsh_material_property` VALUES ('3', '自定义2', '', '03', '自定义2', '0'); -INSERT INTO `jsh_material_property` VALUES ('4', '自定义3', '', '04', '自定义3', '0'); -- ---------------------------- -- Table structure for jsh_msg diff --git a/jshERP-boot/docs/数据库更新记录-首次安装请勿使用.txt b/jshERP-boot/docs/数据库更新记录-首次安装请勿使用.txt index a1736f4fc..3fbf86fae 100644 --- a/jshERP-boot/docs/数据库更新记录-首次安装请勿使用.txt +++ b/jshERP-boot/docs/数据库更新记录-首次安装请勿使用.txt @@ -1635,4 +1635,12 @@ update jsh_function set name='多单位' where number='010103'; -- by jishenghua -- 给地址字段调整长度 -- -------------------------------------------------------- -alter table jsh_supplier change address address varchar(100) DEFAULT NULL COMMENT '地址'; \ No newline at end of file +alter table jsh_supplier change address address varchar(100) DEFAULT NULL COMMENT '地址'; + +-- -------------------------------------------------------- +-- 时间 2025年3月25日 +-- by jishenghua +-- 给产品扩展字段表增加租户id字段 +-- 另外注意:需要手动把商品属性菜单分配给租户角色 +-- -------------------------------------------------------- +alter table jsh_material_property add tenant_id bigint(20) DEFAULT NULL COMMENT '租户id' after another_name; \ No newline at end of file diff --git a/jshERP-boot/src/main/java/com/jsh/erp/config/TenantConfig.java b/jshERP-boot/src/main/java/com/jsh/erp/config/TenantConfig.java index d9812cb4a..4383929ff 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/config/TenantConfig.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/config/TenantConfig.java @@ -54,9 +54,8 @@ public class TenantConfig { Long tenantId = Tools.getTenantIdByToken(token); if (tenantId!=0L) { // 这里可以判断是否过滤表 - if ("jsh_material_property".equals(tableName) || "jsh_sequence".equals(tableName) - || "jsh_function".equals(tableName) || "jsh_platform_config".equals(tableName) - || "jsh_tenant".equals(tableName)) { + if ("jsh_sequence".equals(tableName) || "jsh_function".equals(tableName) + || "jsh_platform_config".equals(tableName) || "jsh_tenant".equals(tableName)) { res = true; } else { res = false; diff --git a/jshERP-boot/src/main/java/com/jsh/erp/controller/MaterialPropertyController.java b/jshERP-boot/src/main/java/com/jsh/erp/controller/MaterialPropertyController.java index 0da64f412..9727c6b37 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/controller/MaterialPropertyController.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/controller/MaterialPropertyController.java @@ -27,8 +27,8 @@ import static com.jsh.erp.utils.ResponseJsonUtil.returnStr; /** * Description * - * @Author: qiankunpingtai - * @Date: 2019/3/29 15:24 + * @Author: jsh + * @Date: 2025/3/25 15:24 */ @RestController @RequestMapping(value = "/materialProperty") @@ -79,6 +79,23 @@ public class MaterialPropertyController extends BaseController { return returnStr(objectMap, update); } + @PostMapping(value = "/addOrUpdate") + @ApiOperation(value = "新增或修改") + public String addOrUpdate(@RequestBody JSONObject obj, HttpServletRequest request)throws Exception { + Map objectMap = new HashMap<>(); + String nativeName = obj.getString("nativeName"); + String anotherName = obj.getString("anotherName"); + boolean exist = materialPropertyService.checkIsNativeNameExist(nativeName); + int res; + if(!exist) { + obj.put("id", null); + res = materialPropertyService.insertMaterialProperty(obj, request); + } else { + res = materialPropertyService.updateMaterialPropertyByNativeName(nativeName, anotherName); + } + return returnStr(objectMap, res); + } + @DeleteMapping(value = "/delete") @ApiOperation(value = "删除") public String deleteResource(@RequestParam("id") Long id, HttpServletRequest request)throws Exception { diff --git a/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/MaterialProperty.java b/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/MaterialProperty.java index 53be4d146..742982817 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/MaterialProperty.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/MaterialProperty.java @@ -11,6 +11,8 @@ public class MaterialProperty { private String anotherName; + private Long tenantId; + private String deleteFlag; public Long getId() { @@ -53,6 +55,14 @@ public class MaterialProperty { this.anotherName = anotherName == null ? null : anotherName.trim(); } + public Long getTenantId() { + return tenantId; + } + + public void setTenantId(Long tenantId) { + this.tenantId = tenantId; + } + public String getDeleteFlag() { return deleteFlag; } diff --git a/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/MaterialPropertyExample.java b/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/MaterialPropertyExample.java index 6c2fe016a..1a5a1133b 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/MaterialPropertyExample.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/datasource/entities/MaterialPropertyExample.java @@ -434,6 +434,66 @@ public class MaterialPropertyExample { return (Criteria) this; } + public Criteria andTenantIdIsNull() { + addCriterion("tenant_id is null"); + return (Criteria) this; + } + + public Criteria andTenantIdIsNotNull() { + addCriterion("tenant_id is not null"); + return (Criteria) this; + } + + public Criteria andTenantIdEqualTo(Long value) { + addCriterion("tenant_id =", value, "tenantId"); + return (Criteria) this; + } + + public Criteria andTenantIdNotEqualTo(Long value) { + addCriterion("tenant_id <>", value, "tenantId"); + return (Criteria) this; + } + + public Criteria andTenantIdGreaterThan(Long value) { + addCriterion("tenant_id >", value, "tenantId"); + return (Criteria) this; + } + + public Criteria andTenantIdGreaterThanOrEqualTo(Long value) { + addCriterion("tenant_id >=", value, "tenantId"); + return (Criteria) this; + } + + public Criteria andTenantIdLessThan(Long value) { + addCriterion("tenant_id <", value, "tenantId"); + return (Criteria) this; + } + + public Criteria andTenantIdLessThanOrEqualTo(Long value) { + addCriterion("tenant_id <=", value, "tenantId"); + return (Criteria) this; + } + + public Criteria andTenantIdIn(List values) { + addCriterion("tenant_id in", values, "tenantId"); + return (Criteria) this; + } + + public Criteria andTenantIdNotIn(List values) { + addCriterion("tenant_id not in", values, "tenantId"); + return (Criteria) this; + } + + public Criteria andTenantIdBetween(Long value1, Long value2) { + addCriterion("tenant_id between", value1, value2, "tenantId"); + return (Criteria) this; + } + + public Criteria andTenantIdNotBetween(Long value1, Long value2) { + addCriterion("tenant_id not between", value1, value2, "tenantId"); + return (Criteria) this; + } + public Criteria andDeleteFlagIsNull() { addCriterion("delete_flag is null"); return (Criteria) this; diff --git a/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/MaterialPropertyMapperEx.java b/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/MaterialPropertyMapperEx.java index f4f8e119a..1a28d9cdb 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/MaterialPropertyMapperEx.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/MaterialPropertyMapperEx.java @@ -13,4 +13,10 @@ public interface MaterialPropertyMapperEx { @Param("name") String name); int batchDeleteMaterialPropertyByIds(@Param("updateTime") Date updateTime, @Param("updater") Long updater, @Param("ids") String ids[]); + + int getCountByNativeName(@Param("nativeName") String nativeName); + + void updateMaterialPropertyByNativeName( + @Param("nativeName") String nativeName, + @Param("anotherName") String anotherName); } \ No newline at end of file diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/MaterialPropertyService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/MaterialPropertyService.java index 3e5ff33d8..4a57f7e4a 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/MaterialPropertyService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/MaterialPropertyService.java @@ -18,8 +18,7 @@ import org.springframework.web.context.request.ServletRequestAttributes; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; -import java.util.Date; -import java.util.List; +import java.util.*; @Service public class MaterialPropertyService { @@ -58,11 +57,34 @@ public class MaterialPropertyService { } public List select(String name)throws Exception { - List list=null; + List list = new ArrayList<>(); try{ - if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { - PageUtils.startPage(); - list = materialPropertyMapperEx.selectByConditionMaterialProperty(name); + MaterialProperty mp1 = new MaterialProperty(); + MaterialProperty mp2 = new MaterialProperty(); + MaterialProperty mp3 = new MaterialProperty(); + mp1.setId(1L); + mp1.setNativeName("扩展1"); + mp1.setAnotherName("扩展1"); + list.add(mp1); + mp2.setId(2L); + mp2.setNativeName("扩展2"); + mp2.setAnotherName("扩展2"); + list.add(mp2); + mp3.setId(3L); + mp3.setNativeName("扩展3"); + mp3.setAnotherName("扩展3"); + list.add(mp3); + PageUtils.startPage(); + List mpList = materialPropertyMapperEx.selectByConditionMaterialProperty(name); + Map mpMap = new HashMap<>(); + for(MaterialProperty mp: mpList) { + mpMap.put(mp.getNativeName(), mp.getAnotherName()); + } + //给list里面的别名和排序做更新 + for(MaterialProperty item: list) { + if(mpMap.get(item.getNativeName())!=null) { + item.setAnotherName(mpMap.get(item.getNativeName())); + } } }catch(Exception e){ JshException.readFail(logger, e); @@ -75,11 +97,9 @@ public class MaterialPropertyService { MaterialProperty materialProperty = JSONObject.parseObject(obj.toJSONString(), MaterialProperty.class); int result=0; try{ - if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { - result = materialPropertyMapper.insertSelective(materialProperty); - logService.insertLog("商品属性", - new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(materialProperty.getNativeName()).toString(), request); - } + result = materialPropertyMapper.insertSelective(materialProperty); + logService.insertLog("商品属性", + new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(materialProperty.getNativeName()).toString(), request); }catch(Exception e){ JshException.writeFail(logger, e); } @@ -91,11 +111,9 @@ public class MaterialPropertyService { MaterialProperty materialProperty = JSONObject.parseObject(obj.toJSONString(), MaterialProperty.class); int result=0; try{ - if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { - result = materialPropertyMapper.updateByPrimaryKeySelective(materialProperty); - logService.insertLog("商品属性", - new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(materialProperty.getNativeName()).toString(), request); - } + result = materialPropertyMapper.updateByPrimaryKeySelective(materialProperty); + logService.insertLog("商品属性", + new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(materialProperty.getNativeName()).toString(), request); }catch(Exception e){ JshException.writeFail(logger, e); } @@ -118,12 +136,10 @@ public class MaterialPropertyService { String [] idArray=ids.split(","); int result=0; try{ - if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { - result = materialPropertyMapperEx.batchDeleteMaterialPropertyByIds(new Date(), userInfo == null ? null : userInfo.getId(), idArray); - logService.insertLog("商品属性", - new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), - ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); - } + result = materialPropertyMapperEx.batchDeleteMaterialPropertyByIds(new Date(), userInfo == null ? null : userInfo.getId(), idArray); + logService.insertLog("商品属性", + new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), + ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); }catch(Exception e){ JshException.writeFail(logger, e); } @@ -133,4 +149,14 @@ public class MaterialPropertyService { public int checkIsNameExist(Long id, String name)throws Exception { return 0; } + + public boolean checkIsNativeNameExist(String nativeName) { + int count = materialPropertyMapperEx.getCountByNativeName(nativeName); + return count>0; + } + + public int updateMaterialPropertyByNativeName(String nativeName, String anotherName) { + materialPropertyMapperEx.updateMaterialPropertyByNativeName(nativeName, anotherName); + return 1; + } } diff --git a/jshERP-boot/src/main/resources/mapper_xml/MaterialPropertyMapper.xml b/jshERP-boot/src/main/resources/mapper_xml/MaterialPropertyMapper.xml index 36e1e589a..fe76bc688 100644 --- a/jshERP-boot/src/main/resources/mapper_xml/MaterialPropertyMapper.xml +++ b/jshERP-boot/src/main/resources/mapper_xml/MaterialPropertyMapper.xml @@ -7,6 +7,7 @@ + @@ -68,7 +69,7 @@ - id, native_name, enabled, sort, another_name, delete_flag + id, native_name, enabled, sort, another_name, tenant_id, delete_flag @@ -22,4 +23,18 @@ ) + + + + + update jsh_material_property + set another_name = #{anotherName} + where native_name = #{nativeName} + and ifnull(delete_flag,'0') !='1' + \ No newline at end of file