From 610e551f3741ccc1479d14021430d9876e859739 Mon Sep 17 00:00:00 2001 From: jiyufei <67400194@qq.com> Date: Fri, 16 Aug 2024 13:56:42 +0800 Subject: [PATCH] =?UTF-8?q?feat():U8=E5=90=8C=E6=AD=A5=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jnpf/service/YysMaterialClassService.java | 1 + .../YysMaterialInformationService.java | 1 + .../jnpf/service/YysSupplierClassService.java | 1 + .../YysSupplierInformationService.java | 2 +- .../service/YysUnitInformationService.java | 1 + .../impl/YysMaterialClassServiceImpl.java | 332 +++++++++-------- .../YysMaterialInformationServiceImpl.java | 313 +++++++++------- .../impl/YysSupplierClassServiceImpl.java | 334 ++++++++++-------- .../YysSupplierInformationServiceImpl.java | 331 +++++++++-------- .../impl/YysUnitInformationServiceImpl.java | 290 +++++++++------ .../YysMaterialClassController.java | 10 + .../YysMaterialInformationController.java | 192 +++++----- .../YysSupplierClassController.java | 46 +-- .../YysSupplierInformationController.java | 12 +- .../YysUnitInformationController.java | 161 +++++---- .../jnpf/entity/YysUnitInformationEntity.java | 2 + .../yysmaterialclass/MaterialClassSync.java | 26 ++ .../MaterialInformationSync.java | 36 ++ .../yyssupplierclass/SupplierClassSync.java | 27 ++ .../SupplierInfoSync.java | 27 ++ .../yysunitinformation/UnitInfoSync.java | 19 + .../src/views/yys/yysinventoryquery/index.vue | 2 + .../src/views/yys/yysmaterialclass/index.vue | 21 ++ .../yys/yysmaterialinformation/index.vue | 21 ++ .../src/views/yys/yyssupplierclass/index.vue | 21 ++ .../yys/yyssupplierinformation/index.vue | 21 ++ .../views/yys/yysunitinformation/index.vue | 21 ++ 27 files changed, 1437 insertions(+), 834 deletions(-) create mode 100644 jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yysmaterialclass/MaterialClassSync.java create mode 100644 jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yysmaterialinformation/MaterialInformationSync.java create mode 100644 jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yyssupplierclass/SupplierClassSync.java create mode 100644 jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yyssupplierinformation/SupplierInfoSync.java create mode 100644 jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yysunitinformation/UnitInfoSync.java diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/YysMaterialClassService.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/YysMaterialClassService.java index 97cf363..ccda983 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/YysMaterialClassService.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/YysMaterialClassService.java @@ -32,4 +32,5 @@ public interface YysMaterialClassService extends IService> test(); + String syncSupplier(); } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/YysUnitInformationService.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/YysUnitInformationService.java index 748b81b..1e10937 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/YysUnitInformationService.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/YysUnitInformationService.java @@ -32,4 +32,5 @@ public interface YysUnitInformationService extends IService implements YysMaterialClassService{ +public class YysMaterialClassServiceImpl extends ServiceImpl implements YysMaterialClassService { @Autowired private GeneraterSwapUtil generaterSwapUtil; @Autowired private UserProvider userProvider; + @Autowired + private JdbcTemplate jdbcTemplate; + @Override - public List getList(YysMaterialClassPagination yysMaterialClassPagination){ - return getTypeList(yysMaterialClassPagination,yysMaterialClassPagination.getDataType()); + public List getList(YysMaterialClassPagination yysMaterialClassPagination) { + return getTypeList(yysMaterialClassPagination, yysMaterialClassPagination.getDataType()); } - /** 列表查询 */ + + /** + * 列表查询 + */ @Override - public List getTypeList(YysMaterialClassPagination yysMaterialClassPagination,String dataType){ - String userId=userProvider.get().getUserId(); - List AllIdList =new ArrayList(); - List> intersectionList =new ArrayList<>(); + public List getTypeList(YysMaterialClassPagination yysMaterialClassPagination, String dataType) { + String userId = userProvider.get().getUserId(); + List AllIdList = new ArrayList(); + List> intersectionList = new ArrayList<>(); boolean isPc = ServletUtil.getHeader("jnpf-origin").equals("pc"); String columnData = !isPc ? YysMaterialClassConstant.getAppColumnData() : YysMaterialClassConstant.getColumnData(); ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class); String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList()); - int total=0; - int yysMaterialClassNum =0; - QueryWrapper yysMaterialClassQueryWrapper=new QueryWrapper<>(); + int total = 0; + int yysMaterialClassNum = 0; + QueryWrapper yysMaterialClassQueryWrapper = new QueryWrapper<>(); List allSuperIDlist = new ArrayList<>(); - String superOp =""; - if (ObjectUtil.isNotEmpty(yysMaterialClassPagination.getSuperQueryJson())){ + String superOp = ""; + if (ObjectUtil.isNotEmpty(yysMaterialClassPagination.getSuperQueryJson())) { List allSuperList = new ArrayList<>(); - List> intersectionSuperList = new ArrayList<>(); + List> intersectionSuperList = new ArrayList<>(); String queryJson = yysMaterialClassPagination.getSuperQueryJson(); SuperJsonModel superJsonModel = JsonUtil.getJsonToBean(queryJson, SuperJsonModel.class); int superNum = 0; QueryWrapper yysMaterialClassSuperWrapper = new QueryWrapper<>(); - yysMaterialClassSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysMaterialClassSuperWrapper,YysMaterialClassEntity.class,queryJson,"0")); + yysMaterialClassSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysMaterialClassSuperWrapper, YysMaterialClassEntity.class, queryJson, "0")); int yysMaterialClassNum1 = yysMaterialClassSuperWrapper.getExpression().getNormal().size(); - if (yysMaterialClassNum1>0){ - List yysMaterialClassList =this.list(yysMaterialClassSuperWrapper).stream().map(YysMaterialClassEntity::getId).collect(Collectors.toList()); + if (yysMaterialClassNum1 > 0) { + List yysMaterialClassList = this.list(yysMaterialClassSuperWrapper).stream().map(YysMaterialClassEntity::getId).collect(Collectors.toList()); allSuperList.addAll(yysMaterialClassList); intersectionSuperList.add(yysMaterialClassList); superNum++; } superOp = superNum > 0 ? superJsonModel.getMatchLogic() : ""; //and or - if(superOp.equalsIgnoreCase("and")){ + if (superOp.equalsIgnoreCase("and")) { allSuperIDlist = generaterSwapUtil.getIntersection(intersectionSuperList); - }else{ + } else { allSuperIDlist = allSuperList; } } List allRuleIDlist = new ArrayList<>(); - String ruleOp =""; - if (ObjectUtil.isNotEmpty(ruleJson)){ + String ruleOp = ""; + if (ObjectUtil.isNotEmpty(ruleJson)) { List allRuleList = new ArrayList<>(); - List> intersectionRuleList = new ArrayList<>(); + List> intersectionRuleList = new ArrayList<>(); SuperJsonModel ruleJsonModel = JsonUtil.getJsonToBean(ruleJson, SuperJsonModel.class); int ruleNum = 0; QueryWrapper yysMaterialClassSuperWrapper = new QueryWrapper<>(); - yysMaterialClassSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysMaterialClassSuperWrapper,YysMaterialClassEntity.class,ruleJson,"0")); + yysMaterialClassSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysMaterialClassSuperWrapper, YysMaterialClassEntity.class, ruleJson, "0")); int yysMaterialClassNum1 = yysMaterialClassSuperWrapper.getExpression().getNormal().size(); - if (yysMaterialClassNum1>0){ - List yysMaterialClassList =this.list(yysMaterialClassSuperWrapper).stream().map(YysMaterialClassEntity::getId).collect(Collectors.toList()); + if (yysMaterialClassNum1 > 0) { + List yysMaterialClassList = this.list(yysMaterialClassSuperWrapper).stream().map(YysMaterialClassEntity::getId).collect(Collectors.toList()); allRuleList.addAll(yysMaterialClassList); intersectionRuleList.add(yysMaterialClassList); ruleNum++; } ruleOp = ruleNum > 0 ? ruleJsonModel.getMatchLogic() : ""; //and or - if(ruleOp.equalsIgnoreCase("and")){ + if (ruleOp.equalsIgnoreCase("and")) { allRuleIDlist = generaterSwapUtil.getIntersection(intersectionRuleList); - }else{ + } else { allRuleIDlist = allRuleList; } } - boolean pcPermission = false; - boolean appPermission = false; - if(isPc && pcPermission){ - if (!userProvider.get().getIsAdministrator()){ - Object yysMaterialClassObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysMaterialClassQueryWrapper,YysMaterialClassEntity.class,yysMaterialClassPagination.getMenuId(),"0")); - if (ObjectUtil.isEmpty(yysMaterialClassObj)){ - return new ArrayList<>(); - } else { - yysMaterialClassQueryWrapper = (QueryWrapper)yysMaterialClassObj; - if( yysMaterialClassQueryWrapper.getExpression().getNormal().size()>0){ - yysMaterialClassNum++; - } - } - } - } - if(!isPc && appPermission){ - if (!userProvider.get().getIsAdministrator()){ - Object yysMaterialClassObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysMaterialClassQueryWrapper,YysMaterialClassEntity.class,yysMaterialClassPagination.getMenuId(),"0")); - if (ObjectUtil.isEmpty(yysMaterialClassObj)){ - return new ArrayList<>(); - } else { - yysMaterialClassQueryWrapper = (QueryWrapper)yysMaterialClassObj; - if( yysMaterialClassQueryWrapper.getExpression().getNormal().size()>0){ - yysMaterialClassNum++; - } + boolean pcPermission = false; + boolean appPermission = false; + if (isPc && pcPermission) { + if (!userProvider.get().getIsAdministrator()) { + Object yysMaterialClassObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysMaterialClassQueryWrapper, YysMaterialClassEntity.class, yysMaterialClassPagination.getMenuId(), "0")); + if (ObjectUtil.isEmpty(yysMaterialClassObj)) { + return new ArrayList<>(); + } else { + yysMaterialClassQueryWrapper = (QueryWrapper) yysMaterialClassObj; + if (yysMaterialClassQueryWrapper.getExpression().getNormal().size() > 0) { + yysMaterialClassNum++; + } + } + } } + if (!isPc && appPermission) { + if (!userProvider.get().getIsAdministrator()) { + Object yysMaterialClassObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysMaterialClassQueryWrapper, YysMaterialClassEntity.class, yysMaterialClassPagination.getMenuId(), "0")); + if (ObjectUtil.isEmpty(yysMaterialClassObj)) { + return new ArrayList<>(); + } else { + yysMaterialClassQueryWrapper = (QueryWrapper) yysMaterialClassObj; + if (yysMaterialClassQueryWrapper.getExpression().getNormal().size() > 0) { + yysMaterialClassNum++; + } + } - } - } - if(isPc){ - if(ObjectUtil.isNotEmpty(yysMaterialClassPagination.getClassName())){ - yysMaterialClassNum++; + } + } + if (isPc) { + if (ObjectUtil.isNotEmpty(yysMaterialClassPagination.getClassName())) { + yysMaterialClassNum++; String value = yysMaterialClassPagination.getClassName() instanceof List ? - JsonUtil.getObjectToString(yysMaterialClassPagination.getClassName()) : - String.valueOf(yysMaterialClassPagination.getClassName()); - yysMaterialClassQueryWrapper.lambda().like(YysMaterialClassEntity::getClassName,value); + JsonUtil.getObjectToString(yysMaterialClassPagination.getClassName()) : + String.valueOf(yysMaterialClassPagination.getClassName()); + yysMaterialClassQueryWrapper.lambda().like(YysMaterialClassEntity::getClassName, value); } - if(ObjectUtil.isNotEmpty(yysMaterialClassPagination.getParentClassification())){ - yysMaterialClassNum++; + if (ObjectUtil.isNotEmpty(yysMaterialClassPagination.getParentClassification())) { + yysMaterialClassNum++; String value = yysMaterialClassPagination.getParentClassification() instanceof List ? - JsonUtil.getObjectToString(yysMaterialClassPagination.getParentClassification()) : - String.valueOf(yysMaterialClassPagination.getParentClassification()); - yysMaterialClassQueryWrapper.lambda().like(YysMaterialClassEntity::getParentClassification,value); + JsonUtil.getObjectToString(yysMaterialClassPagination.getParentClassification()) : + String.valueOf(yysMaterialClassPagination.getParentClassification()); + yysMaterialClassQueryWrapper.lambda().like(YysMaterialClassEntity::getParentClassification, value); } - if(ObjectUtil.isNotEmpty(yysMaterialClassPagination.getEnableStatus())){ - yysMaterialClassNum++; + if (ObjectUtil.isNotEmpty(yysMaterialClassPagination.getEnableStatus())) { + yysMaterialClassNum++; String value = yysMaterialClassPagination.getEnableStatus() instanceof List ? - JsonUtil.getObjectToString(yysMaterialClassPagination.getEnableStatus()) : - String.valueOf(yysMaterialClassPagination.getEnableStatus()); - yysMaterialClassQueryWrapper.lambda().like(YysMaterialClassEntity::getEnableStatus,value); + JsonUtil.getObjectToString(yysMaterialClassPagination.getEnableStatus()) : + String.valueOf(yysMaterialClassPagination.getEnableStatus()); + yysMaterialClassQueryWrapper.lambda().like(YysMaterialClassEntity::getEnableStatus, value); } } List intersection = generaterSwapUtil.getIntersection(intersectionList); - if (total>0){ - if (intersection.size()==0){ + if (total > 0) { + if (intersection.size() == 0) { intersection.add("jnpfNullList"); } yysMaterialClassQueryWrapper.lambda().in(YysMaterialClassEntity::getId, intersection); } - //是否有高级查询 - if (StringUtil.isNotEmpty(superOp)){ - if (allSuperIDlist.size()==0){ + //是否有高级查询 + if (StringUtil.isNotEmpty(superOp)) { + if (allSuperIDlist.size() == 0) { allSuperIDlist.add("jnpfNullList"); } List finalAllSuperIDlist = allSuperIDlist; - yysMaterialClassQueryWrapper.lambda().and(t->t.in(YysMaterialClassEntity::getId, finalAllSuperIDlist)); + yysMaterialClassQueryWrapper.lambda().and(t -> t.in(YysMaterialClassEntity::getId, finalAllSuperIDlist)); } - //是否有数据过滤查询 - if (StringUtil.isNotEmpty(ruleOp)){ - if (allRuleIDlist.size()==0){ + //是否有数据过滤查询 + if (StringUtil.isNotEmpty(ruleOp)) { + if (allRuleIDlist.size() == 0) { allRuleIDlist.add("jnpfNullList"); } List finalAllRuleIDlist = allRuleIDlist; - yysMaterialClassQueryWrapper.lambda().and(t->t.in(YysMaterialClassEntity::getId, finalAllRuleIDlist)); + yysMaterialClassQueryWrapper.lambda().and(t -> t.in(YysMaterialClassEntity::getId, finalAllRuleIDlist)); } //排序 - if(StringUtil.isEmpty(yysMaterialClassPagination.getSidx())){ + if (StringUtil.isEmpty(yysMaterialClassPagination.getSidx())) { yysMaterialClassQueryWrapper.lambda().orderByDesc(YysMaterialClassEntity::getId); - }else{ + } else { try { String sidx = yysMaterialClassPagination.getSidx(); - String[] strs= sidx.split("_name"); + String[] strs = sidx.split("_name"); YysMaterialClassEntity yysMaterialClassEntity = new YysMaterialClassEntity(); Field declaredField = yysMaterialClassEntity.getClass().getDeclaredField(strs[0]); declaredField.setAccessible(true); String value = declaredField.getAnnotation(TableField.class).value(); - yysMaterialClassQueryWrapper="asc".equals(yysMaterialClassPagination.getSort().toLowerCase())?yysMaterialClassQueryWrapper.orderByAsc(value):yysMaterialClassQueryWrapper.orderByDesc(value); + yysMaterialClassQueryWrapper = "asc".equals(yysMaterialClassPagination.getSort().toLowerCase()) ? yysMaterialClassQueryWrapper.orderByAsc(value) : yysMaterialClassQueryWrapper.orderByDesc(value); } catch (NoSuchFieldException e) { e.printStackTrace(); } } - if("0".equals(dataType)){ - if((total>0 && AllIdList.size()>0) || total==0){ - Page page=new Page<>(yysMaterialClassPagination.getCurrentPage(), yysMaterialClassPagination.getPageSize()); - IPage userIPage=this.page(page, yysMaterialClassQueryWrapper); - return yysMaterialClassPagination.setData(userIPage.getRecords(),userIPage.getTotal()); - }else{ + if ("0".equals(dataType)) { + if ((total > 0 && AllIdList.size() > 0) || total == 0) { + Page page = new Page<>(yysMaterialClassPagination.getCurrentPage(), yysMaterialClassPagination.getPageSize()); + IPage userIPage = this.page(page, yysMaterialClassQueryWrapper); + return yysMaterialClassPagination.setData(userIPage.getRecords(), userIPage.getTotal()); + } else { List list = new ArrayList(); return yysMaterialClassPagination.setData(list, list.size()); } - }else{ + } else { return this.list(yysMaterialClassQueryWrapper); } } + @Override - public YysMaterialClassEntity getInfo(String id){ - QueryWrapper queryWrapper=new QueryWrapper<>(); - queryWrapper.lambda().eq(YysMaterialClassEntity::getId,id); + public YysMaterialClassEntity getInfo(String id) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(YysMaterialClassEntity::getId, id); return this.getOne(queryWrapper); } + @Override - public void create(YysMaterialClassEntity entity){ + public void create(YysMaterialClassEntity entity) { this.save(entity); } + @Override - public boolean update(String id, YysMaterialClassEntity entity){ + public boolean update(String id, YysMaterialClassEntity entity) { return this.updateById(entity); } + @Override - public void delete(YysMaterialClassEntity entity){ - if(entity!=null){ + public void delete(YysMaterialClassEntity entity) { + if (entity != null) { this.removeById(entity.getId()); } } - /** 验证表单唯一字段,正则,非空 i-0新增-1修改*/ + + /** + * 验证表单唯一字段,正则,非空 i-0新增-1修改 + */ @Override - public String checkForm(YysMaterialClassForm form,int i) { - boolean isUp =StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0"); - String id=""; + public String checkForm(YysMaterialClassForm form, int i) { + boolean isUp = StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0"); + String id = ""; String countRecover = ""; - if (isUp){ + if (isUp) { id = form.getId(); } //主表字段验证 return countRecover; } + /** - * 新增修改数据(事务回滚) - * @param id - * @param yysMaterialClassForm - * @return - */ + * 新增修改数据(事务回滚) + * + * @param id + * @param yysMaterialClassForm + * @return + */ @Override @Transactional - public void saveOrUpdate(YysMaterialClassForm yysMaterialClassForm,String id, boolean isSave) throws Exception{ - UserInfo userInfo=userProvider.get(); + public void saveOrUpdate(YysMaterialClassForm yysMaterialClassForm, String id, boolean isSave) throws Exception { + UserInfo userInfo = userProvider.get(); UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId()); yysMaterialClassForm = JsonUtil.getJsonToBean( - generaterSwapUtil.swapDatetime(YysMaterialClassConstant.getFormData(),yysMaterialClassForm),YysMaterialClassForm.class); + generaterSwapUtil.swapDatetime(YysMaterialClassConstant.getFormData(), yysMaterialClassForm), YysMaterialClassForm.class); YysMaterialClassEntity entity = JsonUtil.getJsonToBean(yysMaterialClassForm, YysMaterialClassEntity.class); - if(isSave){ - String mainId = RandomUtil.uuId() ; + if (isSave) { + String mainId = RandomUtil.uuId(); entity.setId(mainId); - }else{ + } else { } this.saveOrUpdate(entity); } + + @Override + @DS("slave_2") + public String syncMaterialClass() { + RowMapper rowMapper = new BeanPropertyRowMapper<>(MaterialClassSync.class); + String sql = "select * from dbo.InventoryClass"; + List query = this.jdbcTemplate.query(sql, rowMapper); + if (org.apache.commons.collections4.CollectionUtils.isEmpty(query)) { + return "远程物料分类信息为空"; + } + //过滤出同步过的 + List list = this.list(new LambdaQueryWrapper<>(YysMaterialClassEntity.class).isNull(YysMaterialClassEntity::getDeleteMark)) + .stream().map(YysMaterialClassEntity::getClassId).collect(Collectors.toList()); + List result = Lists.newArrayList(); + for (MaterialClassSync sync : query) { + if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(list) && list.contains(sync.getCInvCCode())) { + continue; + } + YysMaterialClassEntity entity = new YysMaterialClassEntity(); + String mainId = RandomUtil.uuId(); + entity.setId(mainId); + entity.setClassId(sync.getCInvCCode()); + entity.setClassName(sync.getCInvCName()); + entity.setEnableStatus("1"); + result.add(entity); + } + if (CollectionUtils.isEmpty(result)) { + return "没有需要同步的数据"; + } + boolean b = this.saveBatch(result); + if (b) { + return "同步成功"; + } + return "同步失败"; + } } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysMaterialInformationServiceImpl.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysMaterialInformationServiceImpl.java index 0493a5c..007a7af 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysMaterialInformationServiceImpl.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysMaterialInformationServiceImpl.java @@ -1,23 +1,39 @@ package jnpf.service.impl; +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.google.common.collect.Lists; import jnpf.entity.*; import jnpf.mapper.YysMaterialInformationMapper; +import jnpf.model.yyssupplierclass.SupplierClassSync; import jnpf.service.*; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import jnpf.model.yysmaterialinformation.*; + import java.math.BigDecimal; + import cn.hutool.core.util.ObjectUtil; import jnpf.permission.model.authorize.AuthorizeConditionModel; import jnpf.util.GeneraterSwapUtil; import jnpf.database.model.superQuery.SuperQueryJsonModel; import jnpf.database.model.superQuery.ConditionJsonModel; import jnpf.database.model.superQuery.SuperQueryConditionModel; + import java.lang.reflect.Field; + import com.baomidou.mybatisplus.annotation.TableField; + import java.util.regex.Pattern; + import jnpf.model.QueryModel; + import java.util.stream.Collectors; + import jnpf.base.model.ColumnDataModel; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.jdbc.core.BeanPropertyRowMapper; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowMapper; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.core.metadata.IPage; import jnpf.database.model.superQuery.SuperJsonModel; @@ -25,13 +41,17 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; + import java.text.SimpleDateFormat; + import jnpf.util.*; + import java.util.*; + import jnpf.base.UserInfo; import jnpf.permission.entity.UserEntity; + /** - * * yysMaterialInformation * 版本: V3.5 * 版权: 引迈信息技术有限公司(https://www.jnpfsoft.com) @@ -39,259 +59,312 @@ import jnpf.permission.entity.UserEntity; * 日期: 2024-08-08 */ @Service -public class YysMaterialInformationServiceImpl extends ServiceImpl implements YysMaterialInformationService{ +public class YysMaterialInformationServiceImpl extends ServiceImpl implements YysMaterialInformationService { @Autowired private GeneraterSwapUtil generaterSwapUtil; @Autowired private UserProvider userProvider; + @Autowired + private JdbcTemplate jdbcTemplate; + @Override - public List getList(YysMaterialInformationPagination yysMaterialInformationPagination){ - return getTypeList(yysMaterialInformationPagination,yysMaterialInformationPagination.getDataType()); + public List getList(YysMaterialInformationPagination yysMaterialInformationPagination) { + return getTypeList(yysMaterialInformationPagination, yysMaterialInformationPagination.getDataType()); } - /** 列表查询 */ + + /** + * 列表查询 + */ @Override - public List getTypeList(YysMaterialInformationPagination yysMaterialInformationPagination,String dataType){ - String userId=userProvider.get().getUserId(); - List AllIdList =new ArrayList(); - List> intersectionList =new ArrayList<>(); + public List getTypeList(YysMaterialInformationPagination yysMaterialInformationPagination, String dataType) { + String userId = userProvider.get().getUserId(); + List AllIdList = new ArrayList(); + List> intersectionList = new ArrayList<>(); boolean isPc = ServletUtil.getHeader("jnpf-origin").equals("pc"); String columnData = !isPc ? YysMaterialInformationConstant.getAppColumnData() : YysMaterialInformationConstant.getColumnData(); ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class); String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList()); - int total=0; - int yysMaterialInformationNum =0; - QueryWrapper yysMaterialInformationQueryWrapper=new QueryWrapper<>(); + int total = 0; + int yysMaterialInformationNum = 0; + QueryWrapper yysMaterialInformationQueryWrapper = new QueryWrapper<>(); List allSuperIDlist = new ArrayList<>(); - String superOp =""; - if (ObjectUtil.isNotEmpty(yysMaterialInformationPagination.getSuperQueryJson())){ + String superOp = ""; + if (ObjectUtil.isNotEmpty(yysMaterialInformationPagination.getSuperQueryJson())) { List allSuperList = new ArrayList<>(); - List> intersectionSuperList = new ArrayList<>(); + List> intersectionSuperList = new ArrayList<>(); String queryJson = yysMaterialInformationPagination.getSuperQueryJson(); SuperJsonModel superJsonModel = JsonUtil.getJsonToBean(queryJson, SuperJsonModel.class); int superNum = 0; QueryWrapper yysMaterialInformationSuperWrapper = new QueryWrapper<>(); - yysMaterialInformationSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysMaterialInformationSuperWrapper,YysMaterialInformationEntity.class,queryJson,"0")); + yysMaterialInformationSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysMaterialInformationSuperWrapper, YysMaterialInformationEntity.class, queryJson, "0")); int yysMaterialInformationNum1 = yysMaterialInformationSuperWrapper.getExpression().getNormal().size(); - if (yysMaterialInformationNum1>0){ - List yysMaterialInformationList =this.list(yysMaterialInformationSuperWrapper).stream().map(YysMaterialInformationEntity::getId).collect(Collectors.toList()); + if (yysMaterialInformationNum1 > 0) { + List yysMaterialInformationList = this.list(yysMaterialInformationSuperWrapper).stream().map(YysMaterialInformationEntity::getId).collect(Collectors.toList()); allSuperList.addAll(yysMaterialInformationList); intersectionSuperList.add(yysMaterialInformationList); superNum++; } superOp = superNum > 0 ? superJsonModel.getMatchLogic() : ""; //and or - if(superOp.equalsIgnoreCase("and")){ + if (superOp.equalsIgnoreCase("and")) { allSuperIDlist = generaterSwapUtil.getIntersection(intersectionSuperList); - }else{ + } else { allSuperIDlist = allSuperList; } } List allRuleIDlist = new ArrayList<>(); - String ruleOp =""; - if (ObjectUtil.isNotEmpty(ruleJson)){ + String ruleOp = ""; + if (ObjectUtil.isNotEmpty(ruleJson)) { List allRuleList = new ArrayList<>(); - List> intersectionRuleList = new ArrayList<>(); + List> intersectionRuleList = new ArrayList<>(); SuperJsonModel ruleJsonModel = JsonUtil.getJsonToBean(ruleJson, SuperJsonModel.class); int ruleNum = 0; QueryWrapper yysMaterialInformationSuperWrapper = new QueryWrapper<>(); - yysMaterialInformationSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysMaterialInformationSuperWrapper,YysMaterialInformationEntity.class,ruleJson,"0")); + yysMaterialInformationSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysMaterialInformationSuperWrapper, YysMaterialInformationEntity.class, ruleJson, "0")); int yysMaterialInformationNum1 = yysMaterialInformationSuperWrapper.getExpression().getNormal().size(); - if (yysMaterialInformationNum1>0){ - List yysMaterialInformationList =this.list(yysMaterialInformationSuperWrapper).stream().map(YysMaterialInformationEntity::getId).collect(Collectors.toList()); + if (yysMaterialInformationNum1 > 0) { + List yysMaterialInformationList = this.list(yysMaterialInformationSuperWrapper).stream().map(YysMaterialInformationEntity::getId).collect(Collectors.toList()); allRuleList.addAll(yysMaterialInformationList); intersectionRuleList.add(yysMaterialInformationList); ruleNum++; } ruleOp = ruleNum > 0 ? ruleJsonModel.getMatchLogic() : ""; //and or - if(ruleOp.equalsIgnoreCase("and")){ + if (ruleOp.equalsIgnoreCase("and")) { allRuleIDlist = generaterSwapUtil.getIntersection(intersectionRuleList); - }else{ + } else { allRuleIDlist = allRuleList; } } - boolean pcPermission = false; - boolean appPermission = false; - if(isPc && pcPermission){ - if (!userProvider.get().getIsAdministrator()){ - Object yysMaterialInformationObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysMaterialInformationQueryWrapper,YysMaterialInformationEntity.class,yysMaterialInformationPagination.getMenuId(),"0")); - if (ObjectUtil.isEmpty(yysMaterialInformationObj)){ - return new ArrayList<>(); - } else { - yysMaterialInformationQueryWrapper = (QueryWrapper)yysMaterialInformationObj; - if( yysMaterialInformationQueryWrapper.getExpression().getNormal().size()>0){ - yysMaterialInformationNum++; - } - } - } - } - if(!isPc && appPermission){ - if (!userProvider.get().getIsAdministrator()){ - Object yysMaterialInformationObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysMaterialInformationQueryWrapper,YysMaterialInformationEntity.class,yysMaterialInformationPagination.getMenuId(),"0")); - if (ObjectUtil.isEmpty(yysMaterialInformationObj)){ - return new ArrayList<>(); - } else { - yysMaterialInformationQueryWrapper = (QueryWrapper)yysMaterialInformationObj; - if( yysMaterialInformationQueryWrapper.getExpression().getNormal().size()>0){ - yysMaterialInformationNum++; - } + boolean pcPermission = false; + boolean appPermission = false; + if (isPc && pcPermission) { + if (!userProvider.get().getIsAdministrator()) { + Object yysMaterialInformationObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysMaterialInformationQueryWrapper, YysMaterialInformationEntity.class, yysMaterialInformationPagination.getMenuId(), "0")); + if (ObjectUtil.isEmpty(yysMaterialInformationObj)) { + return new ArrayList<>(); + } else { + yysMaterialInformationQueryWrapper = (QueryWrapper) yysMaterialInformationObj; + if (yysMaterialInformationQueryWrapper.getExpression().getNormal().size() > 0) { + yysMaterialInformationNum++; + } + } + } } + if (!isPc && appPermission) { + if (!userProvider.get().getIsAdministrator()) { + Object yysMaterialInformationObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysMaterialInformationQueryWrapper, YysMaterialInformationEntity.class, yysMaterialInformationPagination.getMenuId(), "0")); + if (ObjectUtil.isEmpty(yysMaterialInformationObj)) { + return new ArrayList<>(); + } else { + yysMaterialInformationQueryWrapper = (QueryWrapper) yysMaterialInformationObj; + if (yysMaterialInformationQueryWrapper.getExpression().getNormal().size() > 0) { + yysMaterialInformationNum++; + } + } - } - } - if(isPc){ - if(ObjectUtil.isNotEmpty(yysMaterialInformationPagination.getMaterialId())){ - yysMaterialInformationNum++; + } + } + if (isPc) { + if (ObjectUtil.isNotEmpty(yysMaterialInformationPagination.getMaterialId())) { + yysMaterialInformationNum++; String value = yysMaterialInformationPagination.getMaterialId() instanceof List ? - JsonUtil.getObjectToString(yysMaterialInformationPagination.getMaterialId()) : - String.valueOf(yysMaterialInformationPagination.getMaterialId()); - yysMaterialInformationQueryWrapper.lambda().like(YysMaterialInformationEntity::getMaterialId,value); + JsonUtil.getObjectToString(yysMaterialInformationPagination.getMaterialId()) : + String.valueOf(yysMaterialInformationPagination.getMaterialId()); + yysMaterialInformationQueryWrapper.lambda().like(YysMaterialInformationEntity::getMaterialId, value); } - if(ObjectUtil.isNotEmpty(yysMaterialInformationPagination.getMaterialName())){ - yysMaterialInformationNum++; + if (ObjectUtil.isNotEmpty(yysMaterialInformationPagination.getMaterialName())) { + yysMaterialInformationNum++; String value = yysMaterialInformationPagination.getMaterialName() instanceof List ? - JsonUtil.getObjectToString(yysMaterialInformationPagination.getMaterialName()) : - String.valueOf(yysMaterialInformationPagination.getMaterialName()); - yysMaterialInformationQueryWrapper.lambda().like(YysMaterialInformationEntity::getMaterialName,value); + JsonUtil.getObjectToString(yysMaterialInformationPagination.getMaterialName()) : + String.valueOf(yysMaterialInformationPagination.getMaterialName()); + yysMaterialInformationQueryWrapper.lambda().like(YysMaterialInformationEntity::getMaterialName, value); } - if(ObjectUtil.isNotEmpty(yysMaterialInformationPagination.getMaterialClassification())){ - yysMaterialInformationNum++; + if (ObjectUtil.isNotEmpty(yysMaterialInformationPagination.getMaterialClassification())) { + yysMaterialInformationNum++; String value = yysMaterialInformationPagination.getMaterialClassification() instanceof List ? - JsonUtil.getObjectToString(yysMaterialInformationPagination.getMaterialClassification()) : - String.valueOf(yysMaterialInformationPagination.getMaterialClassification()); - yysMaterialInformationQueryWrapper.lambda().like(YysMaterialInformationEntity::getMaterialClassification,value); + JsonUtil.getObjectToString(yysMaterialInformationPagination.getMaterialClassification()) : + String.valueOf(yysMaterialInformationPagination.getMaterialClassification()); + yysMaterialInformationQueryWrapper.lambda().like(YysMaterialInformationEntity::getMaterialClassification, value); } - if(ObjectUtil.isNotEmpty(yysMaterialInformationPagination.getEnableStatus())){ - yysMaterialInformationNum++; + if (ObjectUtil.isNotEmpty(yysMaterialInformationPagination.getEnableStatus())) { + yysMaterialInformationNum++; String value = yysMaterialInformationPagination.getEnableStatus() instanceof List ? - JsonUtil.getObjectToString(yysMaterialInformationPagination.getEnableStatus()) : - String.valueOf(yysMaterialInformationPagination.getEnableStatus()); - yysMaterialInformationQueryWrapper.lambda().like(YysMaterialInformationEntity::getEnableStatus,value); + JsonUtil.getObjectToString(yysMaterialInformationPagination.getEnableStatus()) : + String.valueOf(yysMaterialInformationPagination.getEnableStatus()); + yysMaterialInformationQueryWrapper.lambda().like(YysMaterialInformationEntity::getEnableStatus, value); } } List intersection = generaterSwapUtil.getIntersection(intersectionList); - if (total>0){ - if (intersection.size()==0){ + if (total > 0) { + if (intersection.size() == 0) { intersection.add("jnpfNullList"); } yysMaterialInformationQueryWrapper.lambda().in(YysMaterialInformationEntity::getId, intersection); } - //是否有高级查询 - if (StringUtil.isNotEmpty(superOp)){ - if (allSuperIDlist.size()==0){ + //是否有高级查询 + if (StringUtil.isNotEmpty(superOp)) { + if (allSuperIDlist.size() == 0) { allSuperIDlist.add("jnpfNullList"); } List finalAllSuperIDlist = allSuperIDlist; - yysMaterialInformationQueryWrapper.lambda().and(t->t.in(YysMaterialInformationEntity::getId, finalAllSuperIDlist)); + yysMaterialInformationQueryWrapper.lambda().and(t -> t.in(YysMaterialInformationEntity::getId, finalAllSuperIDlist)); } - //是否有数据过滤查询 - if (StringUtil.isNotEmpty(ruleOp)){ - if (allRuleIDlist.size()==0){ + //是否有数据过滤查询 + if (StringUtil.isNotEmpty(ruleOp)) { + if (allRuleIDlist.size() == 0) { allRuleIDlist.add("jnpfNullList"); } List finalAllRuleIDlist = allRuleIDlist; - yysMaterialInformationQueryWrapper.lambda().and(t->t.in(YysMaterialInformationEntity::getId, finalAllRuleIDlist)); + yysMaterialInformationQueryWrapper.lambda().and(t -> t.in(YysMaterialInformationEntity::getId, finalAllRuleIDlist)); } //排序 - if(StringUtil.isEmpty(yysMaterialInformationPagination.getSidx())){ + if (StringUtil.isEmpty(yysMaterialInformationPagination.getSidx())) { yysMaterialInformationQueryWrapper.lambda().orderByDesc(YysMaterialInformationEntity::getId); - }else{ + } else { try { String sidx = yysMaterialInformationPagination.getSidx(); - String[] strs= sidx.split("_name"); + String[] strs = sidx.split("_name"); YysMaterialInformationEntity yysMaterialInformationEntity = new YysMaterialInformationEntity(); Field declaredField = yysMaterialInformationEntity.getClass().getDeclaredField(strs[0]); declaredField.setAccessible(true); String value = declaredField.getAnnotation(TableField.class).value(); - yysMaterialInformationQueryWrapper="asc".equals(yysMaterialInformationPagination.getSort().toLowerCase())?yysMaterialInformationQueryWrapper.orderByAsc(value):yysMaterialInformationQueryWrapper.orderByDesc(value); + yysMaterialInformationQueryWrapper = "asc".equals(yysMaterialInformationPagination.getSort().toLowerCase()) ? yysMaterialInformationQueryWrapper.orderByAsc(value) : yysMaterialInformationQueryWrapper.orderByDesc(value); } catch (NoSuchFieldException e) { e.printStackTrace(); } } - if("0".equals(dataType)){ - if((total>0 && AllIdList.size()>0) || total==0){ - Page page=new Page<>(yysMaterialInformationPagination.getCurrentPage(), yysMaterialInformationPagination.getPageSize()); - IPage userIPage=this.page(page, yysMaterialInformationQueryWrapper); - return yysMaterialInformationPagination.setData(userIPage.getRecords(),userIPage.getTotal()); - }else{ + if ("0".equals(dataType)) { + if ((total > 0 && AllIdList.size() > 0) || total == 0) { + Page page = new Page<>(yysMaterialInformationPagination.getCurrentPage(), yysMaterialInformationPagination.getPageSize()); + IPage userIPage = this.page(page, yysMaterialInformationQueryWrapper); + return yysMaterialInformationPagination.setData(userIPage.getRecords(), userIPage.getTotal()); + } else { List list = new ArrayList(); return yysMaterialInformationPagination.setData(list, list.size()); } - }else{ + } else { return this.list(yysMaterialInformationQueryWrapper); } } + @Override - public YysMaterialInformationEntity getInfo(String id){ - QueryWrapper queryWrapper=new QueryWrapper<>(); - queryWrapper.lambda().eq(YysMaterialInformationEntity::getId,id); + public YysMaterialInformationEntity getInfo(String id) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(YysMaterialInformationEntity::getId, id); return this.getOne(queryWrapper); } + @Override - public void create(YysMaterialInformationEntity entity){ + public void create(YysMaterialInformationEntity entity) { this.save(entity); } + @Override - public boolean update(String id, YysMaterialInformationEntity entity){ + public boolean update(String id, YysMaterialInformationEntity entity) { return this.updateById(entity); } + @Override - public void delete(YysMaterialInformationEntity entity){ - if(entity!=null){ + public void delete(YysMaterialInformationEntity entity) { + if (entity != null) { this.removeById(entity.getId()); } } - /** 验证表单唯一字段,正则,非空 i-0新增-1修改*/ + + /** + * 验证表单唯一字段,正则,非空 i-0新增-1修改 + */ @Override - public String checkForm(YysMaterialInformationForm form,int i) { - boolean isUp =StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0"); - String id=""; + public String checkForm(YysMaterialInformationForm form, int i) { + boolean isUp = StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0"); + String id = ""; String countRecover = ""; - if (isUp){ + if (isUp) { id = form.getId(); } //主表字段验证 return countRecover; } + /** - * 新增修改数据(事务回滚) - * @param id - * @param yysMaterialInformationForm - * @return - */ + * 新增修改数据(事务回滚) + * + * @param id + * @param yysMaterialInformationForm + * @return + */ @Override @Transactional - public void saveOrUpdate(YysMaterialInformationForm yysMaterialInformationForm,String id, boolean isSave) throws Exception{ - UserInfo userInfo=userProvider.get(); + public void saveOrUpdate(YysMaterialInformationForm yysMaterialInformationForm, String id, boolean isSave) throws Exception { + UserInfo userInfo = userProvider.get(); UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId()); yysMaterialInformationForm = JsonUtil.getJsonToBean( - generaterSwapUtil.swapDatetime(YysMaterialInformationConstant.getFormData(),yysMaterialInformationForm),YysMaterialInformationForm.class); + generaterSwapUtil.swapDatetime(YysMaterialInformationConstant.getFormData(), yysMaterialInformationForm), YysMaterialInformationForm.class); YysMaterialInformationEntity entity = JsonUtil.getJsonToBean(yysMaterialInformationForm, YysMaterialInformationEntity.class); - if(isSave){ - String mainId = RandomUtil.uuId() ; + if (isSave) { + String mainId = RandomUtil.uuId(); entity.setId(mainId); - }else{ + } else { } this.saveOrUpdate(entity); } + + @Override + @DS("slave_2") + public String syncMaterialInfo() { + RowMapper rowMapper = new BeanPropertyRowMapper<>(MaterialInformationSync.class); + String sql = "select * from dbo.Inventory"; + List query = this.jdbcTemplate.query(sql, rowMapper); + if (org.apache.commons.collections4.CollectionUtils.isEmpty(query)) { + return "远程物料信息为空"; + } + //过滤出同步过的 + List list = this.list(new LambdaQueryWrapper<>(YysMaterialInformationEntity.class).isNull(YysMaterialInformationEntity::getDeleteMark)) + .stream().map(YysMaterialInformationEntity::getMaterialId).collect(Collectors.toList()); + List result = Lists.newArrayList(); + for (MaterialInformationSync sync : query) { + if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(list) && list.contains(sync.getCInvCode())) { + continue; + } + YysMaterialInformationEntity entity = new YysMaterialInformationEntity(); + String mainId = RandomUtil.uuId(); + entity.setId(mainId); + entity.setMaterialId(sync.getCInvCode()); + entity.setMaterialName(sync.getCInvName()); + entity.setMaterialClassification(sync.getCInvCCode()); + entity.setMaterialSname(sync.getCInvAddCode()); + entity.setSafetyStock(sync.getISafeNum()); + entity.setEnableStatus("1"); + result.add(entity); + } + if (CollectionUtils.isEmpty(result)) { + return "没有需要同步的数据"; + } + boolean b = this.saveBatch(result); + if (b) { + return "同步成功"; + } + return "同步失败"; + } } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysSupplierClassServiceImpl.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysSupplierClassServiceImpl.java index e21dfa2..39d9073 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysSupplierClassServiceImpl.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysSupplierClassServiceImpl.java @@ -1,37 +1,42 @@ package jnpf.service.impl; -import jnpf.entity.*; -import jnpf.mapper.YysSupplierClassMapper; -import jnpf.service.*; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import jnpf.model.yyssupplierclass.*; -import java.math.BigDecimal; import cn.hutool.core.util.ObjectUtil; -import jnpf.permission.model.authorize.AuthorizeConditionModel; -import jnpf.util.GeneraterSwapUtil; -import jnpf.database.model.superQuery.SuperQueryJsonModel; -import jnpf.database.model.superQuery.ConditionJsonModel; -import jnpf.database.model.superQuery.SuperQueryConditionModel; -import java.lang.reflect.Field; +import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.annotation.TableField; -import java.util.regex.Pattern; -import jnpf.model.QueryModel; -import java.util.stream.Collectors; -import jnpf.base.model.ColumnDataModel; -import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; -import jnpf.database.model.superQuery.SuperJsonModel; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import java.text.SimpleDateFormat; -import jnpf.util.*; -import java.util.*; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.google.common.collect.Lists; import jnpf.base.UserInfo; +import jnpf.base.model.ColumnDataModel; +import jnpf.database.model.superQuery.SuperJsonModel; +import jnpf.entity.YysSupplierClassEntity; +import jnpf.mapper.YysSupplierClassMapper; +import jnpf.model.QueryModel; +import jnpf.model.yyssupplierclass.SupplierClassSync; +import jnpf.model.yyssupplierclass.YysSupplierClassConstant; +import jnpf.model.yyssupplierclass.YysSupplierClassForm; +import jnpf.model.yyssupplierclass.YysSupplierClassPagination; +import jnpf.model.yyssupplierinformation.SupplierInfoSync; import jnpf.permission.entity.UserEntity; +import jnpf.service.YysSupplierClassService; +import jnpf.util.*; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.BeanPropertyRowMapper; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowMapper; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + /** - * * yysSupplierClass * 版本: V3.5 * 版权: 引迈信息技术有限公司(https://www.jnpfsoft.com) @@ -39,249 +44,300 @@ import jnpf.permission.entity.UserEntity; * 日期: 2024-08-08 */ @Service -public class YysSupplierClassServiceImpl extends ServiceImpl implements YysSupplierClassService{ +public class YysSupplierClassServiceImpl extends ServiceImpl implements YysSupplierClassService { @Autowired private GeneraterSwapUtil generaterSwapUtil; @Autowired private UserProvider userProvider; + @Autowired + private JdbcTemplate jdbcTemplate; + @Override - public List getList(YysSupplierClassPagination yysSupplierClassPagination){ - return getTypeList(yysSupplierClassPagination,yysSupplierClassPagination.getDataType()); + public List getList(YysSupplierClassPagination yysSupplierClassPagination) { + return getTypeList(yysSupplierClassPagination, yysSupplierClassPagination.getDataType()); } - /** 列表查询 */ + + /** + * 列表查询 + */ @Override - public List getTypeList(YysSupplierClassPagination yysSupplierClassPagination,String dataType){ - String userId=userProvider.get().getUserId(); - List AllIdList =new ArrayList(); - List> intersectionList =new ArrayList<>(); + public List getTypeList(YysSupplierClassPagination yysSupplierClassPagination, String dataType) { + String userId = userProvider.get().getUserId(); + List AllIdList = new ArrayList(); + List> intersectionList = new ArrayList<>(); boolean isPc = ServletUtil.getHeader("jnpf-origin").equals("pc"); String columnData = !isPc ? YysSupplierClassConstant.getAppColumnData() : YysSupplierClassConstant.getColumnData(); ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class); String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList()); - int total=0; - int yysSupplierClassNum =0; - QueryWrapper yysSupplierClassQueryWrapper=new QueryWrapper<>(); + int total = 0; + int yysSupplierClassNum = 0; + QueryWrapper yysSupplierClassQueryWrapper = new QueryWrapper<>(); List allSuperIDlist = new ArrayList<>(); - String superOp =""; - if (ObjectUtil.isNotEmpty(yysSupplierClassPagination.getSuperQueryJson())){ + String superOp = ""; + if (ObjectUtil.isNotEmpty(yysSupplierClassPagination.getSuperQueryJson())) { List allSuperList = new ArrayList<>(); - List> intersectionSuperList = new ArrayList<>(); + List> intersectionSuperList = new ArrayList<>(); String queryJson = yysSupplierClassPagination.getSuperQueryJson(); SuperJsonModel superJsonModel = JsonUtil.getJsonToBean(queryJson, SuperJsonModel.class); int superNum = 0; QueryWrapper yysSupplierClassSuperWrapper = new QueryWrapper<>(); - yysSupplierClassSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysSupplierClassSuperWrapper,YysSupplierClassEntity.class,queryJson,"0")); + yysSupplierClassSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysSupplierClassSuperWrapper, YysSupplierClassEntity.class, queryJson, "0")); int yysSupplierClassNum1 = yysSupplierClassSuperWrapper.getExpression().getNormal().size(); - if (yysSupplierClassNum1>0){ - List yysSupplierClassList =this.list(yysSupplierClassSuperWrapper).stream().map(YysSupplierClassEntity::getId).collect(Collectors.toList()); + if (yysSupplierClassNum1 > 0) { + List yysSupplierClassList = this.list(yysSupplierClassSuperWrapper).stream().map(YysSupplierClassEntity::getId).collect(Collectors.toList()); allSuperList.addAll(yysSupplierClassList); intersectionSuperList.add(yysSupplierClassList); superNum++; } superOp = superNum > 0 ? superJsonModel.getMatchLogic() : ""; //and or - if(superOp.equalsIgnoreCase("and")){ + if (superOp.equalsIgnoreCase("and")) { allSuperIDlist = generaterSwapUtil.getIntersection(intersectionSuperList); - }else{ + } else { allSuperIDlist = allSuperList; } } List allRuleIDlist = new ArrayList<>(); - String ruleOp =""; - if (ObjectUtil.isNotEmpty(ruleJson)){ + String ruleOp = ""; + if (ObjectUtil.isNotEmpty(ruleJson)) { List allRuleList = new ArrayList<>(); - List> intersectionRuleList = new ArrayList<>(); + List> intersectionRuleList = new ArrayList<>(); SuperJsonModel ruleJsonModel = JsonUtil.getJsonToBean(ruleJson, SuperJsonModel.class); int ruleNum = 0; QueryWrapper yysSupplierClassSuperWrapper = new QueryWrapper<>(); - yysSupplierClassSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysSupplierClassSuperWrapper,YysSupplierClassEntity.class,ruleJson,"0")); + yysSupplierClassSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysSupplierClassSuperWrapper, YysSupplierClassEntity.class, ruleJson, "0")); int yysSupplierClassNum1 = yysSupplierClassSuperWrapper.getExpression().getNormal().size(); - if (yysSupplierClassNum1>0){ - List yysSupplierClassList =this.list(yysSupplierClassSuperWrapper).stream().map(YysSupplierClassEntity::getId).collect(Collectors.toList()); + if (yysSupplierClassNum1 > 0) { + List yysSupplierClassList = this.list(yysSupplierClassSuperWrapper).stream().map(YysSupplierClassEntity::getId).collect(Collectors.toList()); allRuleList.addAll(yysSupplierClassList); intersectionRuleList.add(yysSupplierClassList); ruleNum++; } ruleOp = ruleNum > 0 ? ruleJsonModel.getMatchLogic() : ""; //and or - if(ruleOp.equalsIgnoreCase("and")){ + if (ruleOp.equalsIgnoreCase("and")) { allRuleIDlist = generaterSwapUtil.getIntersection(intersectionRuleList); - }else{ + } else { allRuleIDlist = allRuleList; } } - boolean pcPermission = false; - boolean appPermission = false; - if(isPc && pcPermission){ - if (!userProvider.get().getIsAdministrator()){ - Object yysSupplierClassObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysSupplierClassQueryWrapper,YysSupplierClassEntity.class,yysSupplierClassPagination.getMenuId(),"0")); - if (ObjectUtil.isEmpty(yysSupplierClassObj)){ - return new ArrayList<>(); - } else { - yysSupplierClassQueryWrapper = (QueryWrapper)yysSupplierClassObj; - if( yysSupplierClassQueryWrapper.getExpression().getNormal().size()>0){ - yysSupplierClassNum++; - } - } - } - } - if(!isPc && appPermission){ - if (!userProvider.get().getIsAdministrator()){ - Object yysSupplierClassObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysSupplierClassQueryWrapper,YysSupplierClassEntity.class,yysSupplierClassPagination.getMenuId(),"0")); - if (ObjectUtil.isEmpty(yysSupplierClassObj)){ - return new ArrayList<>(); - } else { - yysSupplierClassQueryWrapper = (QueryWrapper)yysSupplierClassObj; - if( yysSupplierClassQueryWrapper.getExpression().getNormal().size()>0){ - yysSupplierClassNum++; - } + boolean pcPermission = false; + boolean appPermission = false; + if (isPc && pcPermission) { + if (!userProvider.get().getIsAdministrator()) { + Object yysSupplierClassObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysSupplierClassQueryWrapper, YysSupplierClassEntity.class, yysSupplierClassPagination.getMenuId(), "0")); + if (ObjectUtil.isEmpty(yysSupplierClassObj)) { + return new ArrayList<>(); + } else { + yysSupplierClassQueryWrapper = (QueryWrapper) yysSupplierClassObj; + if (yysSupplierClassQueryWrapper.getExpression().getNormal().size() > 0) { + yysSupplierClassNum++; + } + } + } } + if (!isPc && appPermission) { + if (!userProvider.get().getIsAdministrator()) { + Object yysSupplierClassObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysSupplierClassQueryWrapper, YysSupplierClassEntity.class, yysSupplierClassPagination.getMenuId(), "0")); + if (ObjectUtil.isEmpty(yysSupplierClassObj)) { + return new ArrayList<>(); + } else { + yysSupplierClassQueryWrapper = (QueryWrapper) yysSupplierClassObj; + if (yysSupplierClassQueryWrapper.getExpression().getNormal().size() > 0) { + yysSupplierClassNum++; + } + } - } - } - if(isPc){ - if(ObjectUtil.isNotEmpty(yysSupplierClassPagination.getClassName())){ - yysSupplierClassNum++; + } + } + if (isPc) { + if (ObjectUtil.isNotEmpty(yysSupplierClassPagination.getClassName())) { + yysSupplierClassNum++; String value = yysSupplierClassPagination.getClassName() instanceof List ? - JsonUtil.getObjectToString(yysSupplierClassPagination.getClassName()) : - String.valueOf(yysSupplierClassPagination.getClassName()); - yysSupplierClassQueryWrapper.lambda().like(YysSupplierClassEntity::getClassName,value); + JsonUtil.getObjectToString(yysSupplierClassPagination.getClassName()) : + String.valueOf(yysSupplierClassPagination.getClassName()); + yysSupplierClassQueryWrapper.lambda().like(YysSupplierClassEntity::getClassName, value); } - if(ObjectUtil.isNotEmpty(yysSupplierClassPagination.getParentClassification())){ - yysSupplierClassNum++; + if (ObjectUtil.isNotEmpty(yysSupplierClassPagination.getParentClassification())) { + yysSupplierClassNum++; String value = yysSupplierClassPagination.getParentClassification() instanceof List ? - JsonUtil.getObjectToString(yysSupplierClassPagination.getParentClassification()) : - String.valueOf(yysSupplierClassPagination.getParentClassification()); - yysSupplierClassQueryWrapper.lambda().like(YysSupplierClassEntity::getParentClassification,value); + JsonUtil.getObjectToString(yysSupplierClassPagination.getParentClassification()) : + String.valueOf(yysSupplierClassPagination.getParentClassification()); + yysSupplierClassQueryWrapper.lambda().like(YysSupplierClassEntity::getParentClassification, value); } - if(ObjectUtil.isNotEmpty(yysSupplierClassPagination.getEnableStatus())){ - yysSupplierClassNum++; + if (ObjectUtil.isNotEmpty(yysSupplierClassPagination.getEnableStatus())) { + yysSupplierClassNum++; String value = yysSupplierClassPagination.getEnableStatus() instanceof List ? - JsonUtil.getObjectToString(yysSupplierClassPagination.getEnableStatus()) : - String.valueOf(yysSupplierClassPagination.getEnableStatus()); - yysSupplierClassQueryWrapper.lambda().like(YysSupplierClassEntity::getEnableStatus,value); + JsonUtil.getObjectToString(yysSupplierClassPagination.getEnableStatus()) : + String.valueOf(yysSupplierClassPagination.getEnableStatus()); + yysSupplierClassQueryWrapper.lambda().like(YysSupplierClassEntity::getEnableStatus, value); } } List intersection = generaterSwapUtil.getIntersection(intersectionList); - if (total>0){ - if (intersection.size()==0){ + if (total > 0) { + if (intersection.size() == 0) { intersection.add("jnpfNullList"); } yysSupplierClassQueryWrapper.lambda().in(YysSupplierClassEntity::getId, intersection); } - //是否有高级查询 - if (StringUtil.isNotEmpty(superOp)){ - if (allSuperIDlist.size()==0){ + //是否有高级查询 + if (StringUtil.isNotEmpty(superOp)) { + if (allSuperIDlist.size() == 0) { allSuperIDlist.add("jnpfNullList"); } List finalAllSuperIDlist = allSuperIDlist; - yysSupplierClassQueryWrapper.lambda().and(t->t.in(YysSupplierClassEntity::getId, finalAllSuperIDlist)); + yysSupplierClassQueryWrapper.lambda().and(t -> t.in(YysSupplierClassEntity::getId, finalAllSuperIDlist)); } - //是否有数据过滤查询 - if (StringUtil.isNotEmpty(ruleOp)){ - if (allRuleIDlist.size()==0){ + //是否有数据过滤查询 + if (StringUtil.isNotEmpty(ruleOp)) { + if (allRuleIDlist.size() == 0) { allRuleIDlist.add("jnpfNullList"); } List finalAllRuleIDlist = allRuleIDlist; - yysSupplierClassQueryWrapper.lambda().and(t->t.in(YysSupplierClassEntity::getId, finalAllRuleIDlist)); + yysSupplierClassQueryWrapper.lambda().and(t -> t.in(YysSupplierClassEntity::getId, finalAllRuleIDlist)); } //排序 - if(StringUtil.isEmpty(yysSupplierClassPagination.getSidx())){ + if (StringUtil.isEmpty(yysSupplierClassPagination.getSidx())) { yysSupplierClassQueryWrapper.lambda().orderByDesc(YysSupplierClassEntity::getId); - }else{ + } else { try { String sidx = yysSupplierClassPagination.getSidx(); - String[] strs= sidx.split("_name"); + String[] strs = sidx.split("_name"); YysSupplierClassEntity yysSupplierClassEntity = new YysSupplierClassEntity(); Field declaredField = yysSupplierClassEntity.getClass().getDeclaredField(strs[0]); declaredField.setAccessible(true); String value = declaredField.getAnnotation(TableField.class).value(); - yysSupplierClassQueryWrapper="asc".equals(yysSupplierClassPagination.getSort().toLowerCase())?yysSupplierClassQueryWrapper.orderByAsc(value):yysSupplierClassQueryWrapper.orderByDesc(value); + yysSupplierClassQueryWrapper = "asc".equals(yysSupplierClassPagination.getSort().toLowerCase()) ? yysSupplierClassQueryWrapper.orderByAsc(value) : yysSupplierClassQueryWrapper.orderByDesc(value); } catch (NoSuchFieldException e) { e.printStackTrace(); } } - if("0".equals(dataType)){ - if((total>0 && AllIdList.size()>0) || total==0){ - Page page=new Page<>(yysSupplierClassPagination.getCurrentPage(), yysSupplierClassPagination.getPageSize()); - IPage userIPage=this.page(page, yysSupplierClassQueryWrapper); - return yysSupplierClassPagination.setData(userIPage.getRecords(),userIPage.getTotal()); - }else{ + if ("0".equals(dataType)) { + if ((total > 0 && AllIdList.size() > 0) || total == 0) { + Page page = new Page<>(yysSupplierClassPagination.getCurrentPage(), yysSupplierClassPagination.getPageSize()); + IPage userIPage = this.page(page, yysSupplierClassQueryWrapper); + return yysSupplierClassPagination.setData(userIPage.getRecords(), userIPage.getTotal()); + } else { List list = new ArrayList(); return yysSupplierClassPagination.setData(list, list.size()); } - }else{ + } else { return this.list(yysSupplierClassQueryWrapper); } } + @Override - public YysSupplierClassEntity getInfo(String id){ - QueryWrapper queryWrapper=new QueryWrapper<>(); - queryWrapper.lambda().eq(YysSupplierClassEntity::getId,id); + public YysSupplierClassEntity getInfo(String id) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(YysSupplierClassEntity::getId, id); return this.getOne(queryWrapper); } + @Override - public void create(YysSupplierClassEntity entity){ + public void create(YysSupplierClassEntity entity) { this.save(entity); } + @Override - public boolean update(String id, YysSupplierClassEntity entity){ + public boolean update(String id, YysSupplierClassEntity entity) { return this.updateById(entity); } + @Override - public void delete(YysSupplierClassEntity entity){ - if(entity!=null){ + public void delete(YysSupplierClassEntity entity) { + if (entity != null) { this.removeById(entity.getId()); } } - /** 验证表单唯一字段,正则,非空 i-0新增-1修改*/ + + /** + * 验证表单唯一字段,正则,非空 i-0新增-1修改 + */ @Override - public String checkForm(YysSupplierClassForm form,int i) { - boolean isUp =StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0"); - String id=""; + public String checkForm(YysSupplierClassForm form, int i) { + boolean isUp = StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0"); + String id = ""; String countRecover = ""; - if (isUp){ + if (isUp) { id = form.getId(); } //主表字段验证 return countRecover; } + /** - * 新增修改数据(事务回滚) - * @param id - * @param yysSupplierClassForm - * @return - */ + * 新增修改数据(事务回滚) + * + * @param id + * @param yysSupplierClassForm + * @return + */ @Override @Transactional - public void saveOrUpdate(YysSupplierClassForm yysSupplierClassForm,String id, boolean isSave) throws Exception{ - UserInfo userInfo=userProvider.get(); + public void saveOrUpdate(YysSupplierClassForm yysSupplierClassForm, String id, boolean isSave) throws Exception { + UserInfo userInfo = userProvider.get(); UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId()); yysSupplierClassForm = JsonUtil.getJsonToBean( - generaterSwapUtil.swapDatetime(YysSupplierClassConstant.getFormData(),yysSupplierClassForm),YysSupplierClassForm.class); + generaterSwapUtil.swapDatetime(YysSupplierClassConstant.getFormData(), yysSupplierClassForm), YysSupplierClassForm.class); YysSupplierClassEntity entity = JsonUtil.getJsonToBean(yysSupplierClassForm, YysSupplierClassEntity.class); - if(isSave){ - String mainId = RandomUtil.uuId() ; + if (isSave) { + String mainId = RandomUtil.uuId(); entity.setId(mainId); - }else{ + } else { } this.saveOrUpdate(entity); } + + @Override + @DS("slave_2") + public String syncSupplierClass() { + RowMapper rowMapper = new BeanPropertyRowMapper<>(SupplierClassSync.class); + String sql = "select * from dbo.VendorClass"; + List query = this.jdbcTemplate.query(sql, rowMapper); + if (org.apache.commons.collections4.CollectionUtils.isEmpty(query)) { + return "远程供应商分类信息为空"; + } + //过滤出同步过的 + List list = this.list(new LambdaQueryWrapper<>(YysSupplierClassEntity.class).isNull(YysSupplierClassEntity::getDeleteMark)) + .stream().map(YysSupplierClassEntity::getClassId).collect(Collectors.toList()); + List result = Lists.newArrayList(); + for (SupplierClassSync sync : query) { + if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(list) && list.contains(sync.getCVCCode())) { + continue; + } + YysSupplierClassEntity entity = new YysSupplierClassEntity(); + String mainId = RandomUtil.uuId(); + entity.setId(mainId); + entity.setClassId(sync.getCVCCode()); + entity.setClassName(sync.getCVCName()); + entity.setEnableStatus("1"); + //todo 供应商上级分类 + result.add(entity); + } + if (CollectionUtils.isEmpty(result)) { + return "没有需要同步的数据"; + } + boolean b = this.saveBatch(result); + if (b) { + return "同步成功"; + } + return "同步失败"; + } } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysSupplierInformationServiceImpl.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysSupplierInformationServiceImpl.java index f32e33e..0779759 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysSupplierInformationServiceImpl.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysSupplierInformationServiceImpl.java @@ -1,39 +1,41 @@ package jnpf.service.impl; -import com.baomidou.dynamic.datasource.annotation.DS; -import jnpf.entity.*; -import jnpf.mapper.YysSupplierInformationMapper; -import jnpf.service.*; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import jnpf.model.yyssupplierinformation.*; -import java.math.BigDecimal; import cn.hutool.core.util.ObjectUtil; -import jnpf.permission.model.authorize.AuthorizeConditionModel; -import jnpf.util.GeneraterSwapUtil; -import jnpf.database.model.superQuery.SuperQueryJsonModel; -import jnpf.database.model.superQuery.ConditionJsonModel; -import jnpf.database.model.superQuery.SuperQueryConditionModel; -import java.lang.reflect.Field; +import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.annotation.TableField; -import java.util.regex.Pattern; -import jnpf.model.QueryModel; -import java.util.stream.Collectors; -import jnpf.base.model.ColumnDataModel; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; -import jnpf.database.model.superQuery.SuperJsonModel; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import java.text.SimpleDateFormat; -import jnpf.util.*; -import java.util.*; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.google.common.collect.Lists; import jnpf.base.UserInfo; +import jnpf.base.model.ColumnDataModel; +import jnpf.database.model.superQuery.SuperJsonModel; +import jnpf.entity.YysSupplierInformationEntity; +import jnpf.mapper.YysSupplierInformationMapper; +import jnpf.model.QueryModel; +import jnpf.model.yyssupplierinformation.SupplierInfoSync; +import jnpf.model.yyssupplierinformation.YysSupplierInformationConstant; +import jnpf.model.yyssupplierinformation.YysSupplierInformationForm; +import jnpf.model.yyssupplierinformation.YysSupplierInformationPagination; import jnpf.permission.entity.UserEntity; +import jnpf.service.YysSupplierInformationService; +import jnpf.util.*; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.BeanPropertyRowMapper; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowMapper; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + /** - * * yysSupplierInformation * 版本: V3.5 * 版权: 引迈信息技术有限公司(https://www.jnpfsoft.com) @@ -41,7 +43,7 @@ import jnpf.permission.entity.UserEntity; * 日期: 2024-08-08 */ @Service -public class YysSupplierInformationServiceImpl extends ServiceImpl implements YysSupplierInformationService{ +public class YysSupplierInformationServiceImpl extends ServiceImpl implements YysSupplierInformationService { @Autowired private GeneraterSwapUtil generaterSwapUtil; @@ -52,239 +54,251 @@ public class YysSupplierInformationServiceImpl extends ServiceImpl getList(YysSupplierInformationPagination yysSupplierInformationPagination){ - return getTypeList(yysSupplierInformationPagination,yysSupplierInformationPagination.getDataType()); + public List getList(YysSupplierInformationPagination yysSupplierInformationPagination) { + return getTypeList(yysSupplierInformationPagination, yysSupplierInformationPagination.getDataType()); } - /** 列表查询 */ + + /** + * 列表查询 + */ @Override - public List getTypeList(YysSupplierInformationPagination yysSupplierInformationPagination,String dataType){ - String userId=userProvider.get().getUserId(); - List AllIdList =new ArrayList(); - List> intersectionList =new ArrayList<>(); + public List getTypeList(YysSupplierInformationPagination yysSupplierInformationPagination, String dataType) { + String userId = userProvider.get().getUserId(); + List AllIdList = new ArrayList(); + List> intersectionList = new ArrayList<>(); boolean isPc = ServletUtil.getHeader("jnpf-origin").equals("pc"); String columnData = !isPc ? YysSupplierInformationConstant.getAppColumnData() : YysSupplierInformationConstant.getColumnData(); ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class); String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList()); - int total=0; - int yysSupplierInformationNum =0; - QueryWrapper yysSupplierInformationQueryWrapper=new QueryWrapper<>(); + int total = 0; + int yysSupplierInformationNum = 0; + QueryWrapper yysSupplierInformationQueryWrapper = new QueryWrapper<>(); List allSuperIDlist = new ArrayList<>(); - String superOp =""; - if (ObjectUtil.isNotEmpty(yysSupplierInformationPagination.getSuperQueryJson())){ + String superOp = ""; + if (ObjectUtil.isNotEmpty(yysSupplierInformationPagination.getSuperQueryJson())) { List allSuperList = new ArrayList<>(); - List> intersectionSuperList = new ArrayList<>(); + List> intersectionSuperList = new ArrayList<>(); String queryJson = yysSupplierInformationPagination.getSuperQueryJson(); SuperJsonModel superJsonModel = JsonUtil.getJsonToBean(queryJson, SuperJsonModel.class); int superNum = 0; QueryWrapper yysSupplierInformationSuperWrapper = new QueryWrapper<>(); - yysSupplierInformationSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysSupplierInformationSuperWrapper,YysSupplierInformationEntity.class,queryJson,"0")); + yysSupplierInformationSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysSupplierInformationSuperWrapper, YysSupplierInformationEntity.class, queryJson, "0")); int yysSupplierInformationNum1 = yysSupplierInformationSuperWrapper.getExpression().getNormal().size(); - if (yysSupplierInformationNum1>0){ - List yysSupplierInformationList =this.list(yysSupplierInformationSuperWrapper).stream().map(YysSupplierInformationEntity::getId).collect(Collectors.toList()); + if (yysSupplierInformationNum1 > 0) { + List yysSupplierInformationList = this.list(yysSupplierInformationSuperWrapper).stream().map(YysSupplierInformationEntity::getId).collect(Collectors.toList()); allSuperList.addAll(yysSupplierInformationList); intersectionSuperList.add(yysSupplierInformationList); superNum++; } superOp = superNum > 0 ? superJsonModel.getMatchLogic() : ""; //and or - if(superOp.equalsIgnoreCase("and")){ + if (superOp.equalsIgnoreCase("and")) { allSuperIDlist = generaterSwapUtil.getIntersection(intersectionSuperList); - }else{ + } else { allSuperIDlist = allSuperList; } } List allRuleIDlist = new ArrayList<>(); - String ruleOp =""; - if (ObjectUtil.isNotEmpty(ruleJson)){ + String ruleOp = ""; + if (ObjectUtil.isNotEmpty(ruleJson)) { List allRuleList = new ArrayList<>(); - List> intersectionRuleList = new ArrayList<>(); + List> intersectionRuleList = new ArrayList<>(); SuperJsonModel ruleJsonModel = JsonUtil.getJsonToBean(ruleJson, SuperJsonModel.class); int ruleNum = 0; QueryWrapper yysSupplierInformationSuperWrapper = new QueryWrapper<>(); - yysSupplierInformationSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysSupplierInformationSuperWrapper,YysSupplierInformationEntity.class,ruleJson,"0")); + yysSupplierInformationSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysSupplierInformationSuperWrapper, YysSupplierInformationEntity.class, ruleJson, "0")); int yysSupplierInformationNum1 = yysSupplierInformationSuperWrapper.getExpression().getNormal().size(); - if (yysSupplierInformationNum1>0){ - List yysSupplierInformationList =this.list(yysSupplierInformationSuperWrapper).stream().map(YysSupplierInformationEntity::getId).collect(Collectors.toList()); + if (yysSupplierInformationNum1 > 0) { + List yysSupplierInformationList = this.list(yysSupplierInformationSuperWrapper).stream().map(YysSupplierInformationEntity::getId).collect(Collectors.toList()); allRuleList.addAll(yysSupplierInformationList); intersectionRuleList.add(yysSupplierInformationList); ruleNum++; } ruleOp = ruleNum > 0 ? ruleJsonModel.getMatchLogic() : ""; //and or - if(ruleOp.equalsIgnoreCase("and")){ + if (ruleOp.equalsIgnoreCase("and")) { allRuleIDlist = generaterSwapUtil.getIntersection(intersectionRuleList); - }else{ + } else { allRuleIDlist = allRuleList; } } - boolean pcPermission = false; - boolean appPermission = false; - if(isPc && pcPermission){ - if (!userProvider.get().getIsAdministrator()){ - Object yysSupplierInformationObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysSupplierInformationQueryWrapper,YysSupplierInformationEntity.class,yysSupplierInformationPagination.getMenuId(),"0")); - if (ObjectUtil.isEmpty(yysSupplierInformationObj)){ - return new ArrayList<>(); - } else { - yysSupplierInformationQueryWrapper = (QueryWrapper)yysSupplierInformationObj; - if( yysSupplierInformationQueryWrapper.getExpression().getNormal().size()>0){ - yysSupplierInformationNum++; - } - } - } - } - if(!isPc && appPermission){ - if (!userProvider.get().getIsAdministrator()){ - Object yysSupplierInformationObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysSupplierInformationQueryWrapper,YysSupplierInformationEntity.class,yysSupplierInformationPagination.getMenuId(),"0")); - if (ObjectUtil.isEmpty(yysSupplierInformationObj)){ - return new ArrayList<>(); - } else { - yysSupplierInformationQueryWrapper = (QueryWrapper)yysSupplierInformationObj; - if( yysSupplierInformationQueryWrapper.getExpression().getNormal().size()>0){ - yysSupplierInformationNum++; - } + boolean pcPermission = false; + boolean appPermission = false; + if (isPc && pcPermission) { + if (!userProvider.get().getIsAdministrator()) { + Object yysSupplierInformationObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysSupplierInformationQueryWrapper, YysSupplierInformationEntity.class, yysSupplierInformationPagination.getMenuId(), "0")); + if (ObjectUtil.isEmpty(yysSupplierInformationObj)) { + return new ArrayList<>(); + } else { + yysSupplierInformationQueryWrapper = (QueryWrapper) yysSupplierInformationObj; + if (yysSupplierInformationQueryWrapper.getExpression().getNormal().size() > 0) { + yysSupplierInformationNum++; + } + } + } } + if (!isPc && appPermission) { + if (!userProvider.get().getIsAdministrator()) { + Object yysSupplierInformationObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysSupplierInformationQueryWrapper, YysSupplierInformationEntity.class, yysSupplierInformationPagination.getMenuId(), "0")); + if (ObjectUtil.isEmpty(yysSupplierInformationObj)) { + return new ArrayList<>(); + } else { + yysSupplierInformationQueryWrapper = (QueryWrapper) yysSupplierInformationObj; + if (yysSupplierInformationQueryWrapper.getExpression().getNormal().size() > 0) { + yysSupplierInformationNum++; + } + } - } - } - if(isPc){ - if(ObjectUtil.isNotEmpty(yysSupplierInformationPagination.getSupplierId())){ - yysSupplierInformationNum++; + } + } + if (isPc) { + if (ObjectUtil.isNotEmpty(yysSupplierInformationPagination.getSupplierId())) { + yysSupplierInformationNum++; String value = yysSupplierInformationPagination.getSupplierId() instanceof List ? - JsonUtil.getObjectToString(yysSupplierInformationPagination.getSupplierId()) : - String.valueOf(yysSupplierInformationPagination.getSupplierId()); - yysSupplierInformationQueryWrapper.lambda().like(YysSupplierInformationEntity::getSupplierId,value); + JsonUtil.getObjectToString(yysSupplierInformationPagination.getSupplierId()) : + String.valueOf(yysSupplierInformationPagination.getSupplierId()); + yysSupplierInformationQueryWrapper.lambda().like(YysSupplierInformationEntity::getSupplierId, value); } - if(ObjectUtil.isNotEmpty(yysSupplierInformationPagination.getSupplierSname())){ - yysSupplierInformationNum++; + if (ObjectUtil.isNotEmpty(yysSupplierInformationPagination.getSupplierSname())) { + yysSupplierInformationNum++; String value = yysSupplierInformationPagination.getSupplierSname() instanceof List ? - JsonUtil.getObjectToString(yysSupplierInformationPagination.getSupplierSname()) : - String.valueOf(yysSupplierInformationPagination.getSupplierSname()); - yysSupplierInformationQueryWrapper.lambda().like(YysSupplierInformationEntity::getSupplierSname,value); + JsonUtil.getObjectToString(yysSupplierInformationPagination.getSupplierSname()) : + String.valueOf(yysSupplierInformationPagination.getSupplierSname()); + yysSupplierInformationQueryWrapper.lambda().like(YysSupplierInformationEntity::getSupplierSname, value); } - if(ObjectUtil.isNotEmpty(yysSupplierInformationPagination.getEnableStatus())){ - yysSupplierInformationNum++; + if (ObjectUtil.isNotEmpty(yysSupplierInformationPagination.getEnableStatus())) { + yysSupplierInformationNum++; String value = yysSupplierInformationPagination.getEnableStatus() instanceof List ? - JsonUtil.getObjectToString(yysSupplierInformationPagination.getEnableStatus()) : - String.valueOf(yysSupplierInformationPagination.getEnableStatus()); - yysSupplierInformationQueryWrapper.lambda().like(YysSupplierInformationEntity::getEnableStatus,value); + JsonUtil.getObjectToString(yysSupplierInformationPagination.getEnableStatus()) : + String.valueOf(yysSupplierInformationPagination.getEnableStatus()); + yysSupplierInformationQueryWrapper.lambda().like(YysSupplierInformationEntity::getEnableStatus, value); } } List intersection = generaterSwapUtil.getIntersection(intersectionList); - if (total>0){ - if (intersection.size()==0){ + if (total > 0) { + if (intersection.size() == 0) { intersection.add("jnpfNullList"); } yysSupplierInformationQueryWrapper.lambda().in(YysSupplierInformationEntity::getId, intersection); } - //是否有高级查询 - if (StringUtil.isNotEmpty(superOp)){ - if (allSuperIDlist.size()==0){ + //是否有高级查询 + if (StringUtil.isNotEmpty(superOp)) { + if (allSuperIDlist.size() == 0) { allSuperIDlist.add("jnpfNullList"); } List finalAllSuperIDlist = allSuperIDlist; - yysSupplierInformationQueryWrapper.lambda().and(t->t.in(YysSupplierInformationEntity::getId, finalAllSuperIDlist)); + yysSupplierInformationQueryWrapper.lambda().and(t -> t.in(YysSupplierInformationEntity::getId, finalAllSuperIDlist)); } - //是否有数据过滤查询 - if (StringUtil.isNotEmpty(ruleOp)){ - if (allRuleIDlist.size()==0){ + //是否有数据过滤查询 + if (StringUtil.isNotEmpty(ruleOp)) { + if (allRuleIDlist.size() == 0) { allRuleIDlist.add("jnpfNullList"); } List finalAllRuleIDlist = allRuleIDlist; - yysSupplierInformationQueryWrapper.lambda().and(t->t.in(YysSupplierInformationEntity::getId, finalAllRuleIDlist)); + yysSupplierInformationQueryWrapper.lambda().and(t -> t.in(YysSupplierInformationEntity::getId, finalAllRuleIDlist)); } //排序 - if(StringUtil.isEmpty(yysSupplierInformationPagination.getSidx())){ + if (StringUtil.isEmpty(yysSupplierInformationPagination.getSidx())) { yysSupplierInformationQueryWrapper.lambda().orderByDesc(YysSupplierInformationEntity::getId); - }else{ + } else { try { String sidx = yysSupplierInformationPagination.getSidx(); - String[] strs= sidx.split("_name"); + String[] strs = sidx.split("_name"); YysSupplierInformationEntity yysSupplierInformationEntity = new YysSupplierInformationEntity(); Field declaredField = yysSupplierInformationEntity.getClass().getDeclaredField(strs[0]); declaredField.setAccessible(true); String value = declaredField.getAnnotation(TableField.class).value(); - yysSupplierInformationQueryWrapper="asc".equals(yysSupplierInformationPagination.getSort().toLowerCase())?yysSupplierInformationQueryWrapper.orderByAsc(value):yysSupplierInformationQueryWrapper.orderByDesc(value); + yysSupplierInformationQueryWrapper = "asc".equals(yysSupplierInformationPagination.getSort().toLowerCase()) ? yysSupplierInformationQueryWrapper.orderByAsc(value) : yysSupplierInformationQueryWrapper.orderByDesc(value); } catch (NoSuchFieldException e) { e.printStackTrace(); } } - if("0".equals(dataType)){ - if((total>0 && AllIdList.size()>0) || total==0){ - Page page=new Page<>(yysSupplierInformationPagination.getCurrentPage(), yysSupplierInformationPagination.getPageSize()); - IPage userIPage=this.page(page, yysSupplierInformationQueryWrapper); - return yysSupplierInformationPagination.setData(userIPage.getRecords(),userIPage.getTotal()); - }else{ + if ("0".equals(dataType)) { + if ((total > 0 && AllIdList.size() > 0) || total == 0) { + Page page = new Page<>(yysSupplierInformationPagination.getCurrentPage(), yysSupplierInformationPagination.getPageSize()); + IPage userIPage = this.page(page, yysSupplierInformationQueryWrapper); + return yysSupplierInformationPagination.setData(userIPage.getRecords(), userIPage.getTotal()); + } else { List list = new ArrayList(); return yysSupplierInformationPagination.setData(list, list.size()); } - }else{ + } else { return this.list(yysSupplierInformationQueryWrapper); } } + @Override - public YysSupplierInformationEntity getInfo(String id){ - QueryWrapper queryWrapper=new QueryWrapper<>(); - queryWrapper.lambda().eq(YysSupplierInformationEntity::getId,id); + public YysSupplierInformationEntity getInfo(String id) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(YysSupplierInformationEntity::getId, id); return this.getOne(queryWrapper); } + @Override - public void create(YysSupplierInformationEntity entity){ + public void create(YysSupplierInformationEntity entity) { this.save(entity); } + @Override - public boolean update(String id, YysSupplierInformationEntity entity){ + public boolean update(String id, YysSupplierInformationEntity entity) { return this.updateById(entity); } + @Override - public void delete(YysSupplierInformationEntity entity){ - if(entity!=null){ + public void delete(YysSupplierInformationEntity entity) { + if (entity != null) { this.removeById(entity.getId()); } } - /** 验证表单唯一字段,正则,非空 i-0新增-1修改*/ + + /** + * 验证表单唯一字段,正则,非空 i-0新增-1修改 + */ @Override - public String checkForm(YysSupplierInformationForm form,int i) { - boolean isUp =StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0"); - String id=""; + public String checkForm(YysSupplierInformationForm form, int i) { + boolean isUp = StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0"); + String id = ""; String countRecover = ""; - if (isUp){ + if (isUp) { id = form.getId(); } //主表字段验证 return countRecover; } + /** - * 新增修改数据(事务回滚) - * @param id - * @param yysSupplierInformationForm - * @return - */ + * 新增修改数据(事务回滚) + * + * @param id + * @param yysSupplierInformationForm + * @return + */ @Override @Transactional - public void saveOrUpdate(YysSupplierInformationForm yysSupplierInformationForm,String id, boolean isSave) throws Exception{ - UserInfo userInfo=userProvider.get(); + public void saveOrUpdate(YysSupplierInformationForm yysSupplierInformationForm, String id, boolean isSave) throws Exception { + UserInfo userInfo = userProvider.get(); UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId()); yysSupplierInformationForm = JsonUtil.getJsonToBean( - generaterSwapUtil.swapDatetime(YysSupplierInformationConstant.getFormData(),yysSupplierInformationForm),YysSupplierInformationForm.class); + generaterSwapUtil.swapDatetime(YysSupplierInformationConstant.getFormData(), yysSupplierInformationForm), YysSupplierInformationForm.class); YysSupplierInformationEntity entity = JsonUtil.getJsonToBean(yysSupplierInformationForm, YysSupplierInformationEntity.class); - if(isSave){ - String mainId = RandomUtil.uuId() ; + if (isSave) { + String mainId = RandomUtil.uuId(); entity.setId(mainId); - }else{ + } else { } this.saveOrUpdate(entity); @@ -292,8 +306,39 @@ public class YysSupplierInformationServiceImpl extends ServiceImpl> test() { + public String syncSupplier() { + RowMapper rowMapper = new BeanPropertyRowMapper<>(SupplierInfoSync.class); String sql = "select * from dbo.Vendor"; - return jdbcTemplate.queryForList(sql); + List query = this.jdbcTemplate.query(sql, rowMapper); + if (CollectionUtils.isEmpty(query)) { + return "远程供应商信息为空"; + } + //过滤出同步过的 + List list = this.list(new LambdaQueryWrapper<>(YysSupplierInformationEntity.class).isNull(YysSupplierInformationEntity::getDeleteMark)) + .stream().map(YysSupplierInformationEntity::getSupplierId).collect(Collectors.toList()); + List result = Lists.newArrayList(); + for (SupplierInfoSync sync : query) { + if (CollectionUtils.isNotEmpty(list) && list.contains(sync.getCVenCode())) { + continue; + } + YysSupplierInformationEntity entity = new YysSupplierInformationEntity(); + String mainId = RandomUtil.uuId(); + entity.setId(mainId); + entity.setSupplierId(sync.getCVenCode()); + entity.setSupplierSname(sync.getCVenAbbName()); + entity.setSupplierCname(sync.getCVenName()); + entity.setEnableStatus("1"); + //todo 供应商分类 有待商榷 + entity.setSupplierClassification(sync.getCVCCode()); + result.add(entity); + } + if (CollectionUtils.isEmpty(result)) { + return "没有需要同步的数据"; + } + boolean b = this.saveBatch(result); + if (b) { + return "同步成功"; + } + return "同步失败"; } } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysUnitInformationServiceImpl.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysUnitInformationServiceImpl.java index 8314ada..cef4804 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysUnitInformationServiceImpl.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/YysUnitInformationServiceImpl.java @@ -1,23 +1,39 @@ package jnpf.service.impl; +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.google.common.collect.Lists; import jnpf.entity.*; import jnpf.mapper.YysUnitInformationMapper; +import jnpf.model.yyssupplierinformation.SupplierInfoSync; import jnpf.service.*; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import jnpf.model.yysunitinformation.*; + import java.math.BigDecimal; + import cn.hutool.core.util.ObjectUtil; import jnpf.permission.model.authorize.AuthorizeConditionModel; import jnpf.util.GeneraterSwapUtil; import jnpf.database.model.superQuery.SuperQueryJsonModel; import jnpf.database.model.superQuery.ConditionJsonModel; import jnpf.database.model.superQuery.SuperQueryConditionModel; + import java.lang.reflect.Field; + import com.baomidou.mybatisplus.annotation.TableField; + import java.util.regex.Pattern; + import jnpf.model.QueryModel; + import java.util.stream.Collectors; + import jnpf.base.model.ColumnDataModel; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.jdbc.core.BeanPropertyRowMapper; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowMapper; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.core.metadata.IPage; import jnpf.database.model.superQuery.SuperJsonModel; @@ -25,13 +41,17 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; + import java.text.SimpleDateFormat; + import jnpf.util.*; + import java.util.*; + import jnpf.base.UserInfo; import jnpf.permission.entity.UserEntity; + /** - * * yysUnitInformation * 版本: V3.5 * 版权: 引迈信息技术有限公司(https://www.jnpfsoft.com) @@ -39,239 +59,289 @@ import jnpf.permission.entity.UserEntity; * 日期: 2024-08-08 */ @Service -public class YysUnitInformationServiceImpl extends ServiceImpl implements YysUnitInformationService{ +public class YysUnitInformationServiceImpl extends ServiceImpl implements YysUnitInformationService { @Autowired private GeneraterSwapUtil generaterSwapUtil; @Autowired private UserProvider userProvider; + @Autowired + private JdbcTemplate jdbcTemplate; + @Override - public List getList(YysUnitInformationPagination yysUnitInformationPagination){ - return getTypeList(yysUnitInformationPagination,yysUnitInformationPagination.getDataType()); + public List getList(YysUnitInformationPagination yysUnitInformationPagination) { + return getTypeList(yysUnitInformationPagination, yysUnitInformationPagination.getDataType()); } - /** 列表查询 */ + + /** + * 列表查询 + */ @Override - public List getTypeList(YysUnitInformationPagination yysUnitInformationPagination,String dataType){ - String userId=userProvider.get().getUserId(); - List AllIdList =new ArrayList(); - List> intersectionList =new ArrayList<>(); + public List getTypeList(YysUnitInformationPagination yysUnitInformationPagination, String dataType) { + String userId = userProvider.get().getUserId(); + List AllIdList = new ArrayList(); + List> intersectionList = new ArrayList<>(); boolean isPc = ServletUtil.getHeader("jnpf-origin").equals("pc"); String columnData = !isPc ? YysUnitInformationConstant.getAppColumnData() : YysUnitInformationConstant.getColumnData(); ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class); String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList()); - int total=0; - int yysUnitInformationNum =0; - QueryWrapper yysUnitInformationQueryWrapper=new QueryWrapper<>(); + int total = 0; + int yysUnitInformationNum = 0; + QueryWrapper yysUnitInformationQueryWrapper = new QueryWrapper<>(); List allSuperIDlist = new ArrayList<>(); - String superOp =""; - if (ObjectUtil.isNotEmpty(yysUnitInformationPagination.getSuperQueryJson())){ + String superOp = ""; + if (ObjectUtil.isNotEmpty(yysUnitInformationPagination.getSuperQueryJson())) { List allSuperList = new ArrayList<>(); - List> intersectionSuperList = new ArrayList<>(); + List> intersectionSuperList = new ArrayList<>(); String queryJson = yysUnitInformationPagination.getSuperQueryJson(); SuperJsonModel superJsonModel = JsonUtil.getJsonToBean(queryJson, SuperJsonModel.class); int superNum = 0; QueryWrapper yysUnitInformationSuperWrapper = new QueryWrapper<>(); - yysUnitInformationSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysUnitInformationSuperWrapper,YysUnitInformationEntity.class,queryJson,"0")); + yysUnitInformationSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysUnitInformationSuperWrapper, YysUnitInformationEntity.class, queryJson, "0")); int yysUnitInformationNum1 = yysUnitInformationSuperWrapper.getExpression().getNormal().size(); - if (yysUnitInformationNum1>0){ - List yysUnitInformationList =this.list(yysUnitInformationSuperWrapper).stream().map(YysUnitInformationEntity::getId).collect(Collectors.toList()); + if (yysUnitInformationNum1 > 0) { + List yysUnitInformationList = this.list(yysUnitInformationSuperWrapper).stream().map(YysUnitInformationEntity::getId).collect(Collectors.toList()); allSuperList.addAll(yysUnitInformationList); intersectionSuperList.add(yysUnitInformationList); superNum++; } superOp = superNum > 0 ? superJsonModel.getMatchLogic() : ""; //and or - if(superOp.equalsIgnoreCase("and")){ + if (superOp.equalsIgnoreCase("and")) { allSuperIDlist = generaterSwapUtil.getIntersection(intersectionSuperList); - }else{ + } else { allSuperIDlist = allSuperList; } } List allRuleIDlist = new ArrayList<>(); - String ruleOp =""; - if (ObjectUtil.isNotEmpty(ruleJson)){ + String ruleOp = ""; + if (ObjectUtil.isNotEmpty(ruleJson)) { List allRuleList = new ArrayList<>(); - List> intersectionRuleList = new ArrayList<>(); + List> intersectionRuleList = new ArrayList<>(); SuperJsonModel ruleJsonModel = JsonUtil.getJsonToBean(ruleJson, SuperJsonModel.class); int ruleNum = 0; QueryWrapper yysUnitInformationSuperWrapper = new QueryWrapper<>(); - yysUnitInformationSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysUnitInformationSuperWrapper,YysUnitInformationEntity.class,ruleJson,"0")); + yysUnitInformationSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysUnitInformationSuperWrapper, YysUnitInformationEntity.class, ruleJson, "0")); int yysUnitInformationNum1 = yysUnitInformationSuperWrapper.getExpression().getNormal().size(); - if (yysUnitInformationNum1>0){ - List yysUnitInformationList =this.list(yysUnitInformationSuperWrapper).stream().map(YysUnitInformationEntity::getId).collect(Collectors.toList()); + if (yysUnitInformationNum1 > 0) { + List yysUnitInformationList = this.list(yysUnitInformationSuperWrapper).stream().map(YysUnitInformationEntity::getId).collect(Collectors.toList()); allRuleList.addAll(yysUnitInformationList); intersectionRuleList.add(yysUnitInformationList); ruleNum++; } ruleOp = ruleNum > 0 ? ruleJsonModel.getMatchLogic() : ""; //and or - if(ruleOp.equalsIgnoreCase("and")){ + if (ruleOp.equalsIgnoreCase("and")) { allRuleIDlist = generaterSwapUtil.getIntersection(intersectionRuleList); - }else{ + } else { allRuleIDlist = allRuleList; } } - boolean pcPermission = false; - boolean appPermission = false; - if(isPc && pcPermission){ - if (!userProvider.get().getIsAdministrator()){ - Object yysUnitInformationObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysUnitInformationQueryWrapper,YysUnitInformationEntity.class,yysUnitInformationPagination.getMenuId(),"0")); - if (ObjectUtil.isEmpty(yysUnitInformationObj)){ - return new ArrayList<>(); - } else { - yysUnitInformationQueryWrapper = (QueryWrapper)yysUnitInformationObj; - if( yysUnitInformationQueryWrapper.getExpression().getNormal().size()>0){ - yysUnitInformationNum++; - } - } - } - } - if(!isPc && appPermission){ - if (!userProvider.get().getIsAdministrator()){ - Object yysUnitInformationObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysUnitInformationQueryWrapper,YysUnitInformationEntity.class,yysUnitInformationPagination.getMenuId(),"0")); - if (ObjectUtil.isEmpty(yysUnitInformationObj)){ - return new ArrayList<>(); - } else { - yysUnitInformationQueryWrapper = (QueryWrapper)yysUnitInformationObj; - if( yysUnitInformationQueryWrapper.getExpression().getNormal().size()>0){ - yysUnitInformationNum++; - } + boolean pcPermission = false; + boolean appPermission = false; + if (isPc && pcPermission) { + if (!userProvider.get().getIsAdministrator()) { + Object yysUnitInformationObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysUnitInformationQueryWrapper, YysUnitInformationEntity.class, yysUnitInformationPagination.getMenuId(), "0")); + if (ObjectUtil.isEmpty(yysUnitInformationObj)) { + return new ArrayList<>(); + } else { + yysUnitInformationQueryWrapper = (QueryWrapper) yysUnitInformationObj; + if (yysUnitInformationQueryWrapper.getExpression().getNormal().size() > 0) { + yysUnitInformationNum++; + } + } + } } + if (!isPc && appPermission) { + if (!userProvider.get().getIsAdministrator()) { + Object yysUnitInformationObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysUnitInformationQueryWrapper, YysUnitInformationEntity.class, yysUnitInformationPagination.getMenuId(), "0")); + if (ObjectUtil.isEmpty(yysUnitInformationObj)) { + return new ArrayList<>(); + } else { + yysUnitInformationQueryWrapper = (QueryWrapper) yysUnitInformationObj; + if (yysUnitInformationQueryWrapper.getExpression().getNormal().size() > 0) { + yysUnitInformationNum++; + } + } - } - } - if(isPc){ - if(ObjectUtil.isNotEmpty(yysUnitInformationPagination.getUnitName())){ - yysUnitInformationNum++; + } + } + if (isPc) { + if (ObjectUtil.isNotEmpty(yysUnitInformationPagination.getUnitName())) { + yysUnitInformationNum++; String value = yysUnitInformationPagination.getUnitName() instanceof List ? - JsonUtil.getObjectToString(yysUnitInformationPagination.getUnitName()) : - String.valueOf(yysUnitInformationPagination.getUnitName()); - yysUnitInformationQueryWrapper.lambda().like(YysUnitInformationEntity::getUnitName,value); + JsonUtil.getObjectToString(yysUnitInformationPagination.getUnitName()) : + String.valueOf(yysUnitInformationPagination.getUnitName()); + yysUnitInformationQueryWrapper.lambda().like(YysUnitInformationEntity::getUnitName, value); } - if(ObjectUtil.isNotEmpty(yysUnitInformationPagination.getEnableStatus())){ - yysUnitInformationNum++; + if (ObjectUtil.isNotEmpty(yysUnitInformationPagination.getEnableStatus())) { + yysUnitInformationNum++; String value = yysUnitInformationPagination.getEnableStatus() instanceof List ? - JsonUtil.getObjectToString(yysUnitInformationPagination.getEnableStatus()) : - String.valueOf(yysUnitInformationPagination.getEnableStatus()); - yysUnitInformationQueryWrapper.lambda().like(YysUnitInformationEntity::getEnableStatus,value); + JsonUtil.getObjectToString(yysUnitInformationPagination.getEnableStatus()) : + String.valueOf(yysUnitInformationPagination.getEnableStatus()); + yysUnitInformationQueryWrapper.lambda().like(YysUnitInformationEntity::getEnableStatus, value); } } List intersection = generaterSwapUtil.getIntersection(intersectionList); - if (total>0){ - if (intersection.size()==0){ + if (total > 0) { + if (intersection.size() == 0) { intersection.add("jnpfNullList"); } yysUnitInformationQueryWrapper.lambda().in(YysUnitInformationEntity::getId, intersection); } - //是否有高级查询 - if (StringUtil.isNotEmpty(superOp)){ - if (allSuperIDlist.size()==0){ + //是否有高级查询 + if (StringUtil.isNotEmpty(superOp)) { + if (allSuperIDlist.size() == 0) { allSuperIDlist.add("jnpfNullList"); } List finalAllSuperIDlist = allSuperIDlist; - yysUnitInformationQueryWrapper.lambda().and(t->t.in(YysUnitInformationEntity::getId, finalAllSuperIDlist)); + yysUnitInformationQueryWrapper.lambda().and(t -> t.in(YysUnitInformationEntity::getId, finalAllSuperIDlist)); } - //是否有数据过滤查询 - if (StringUtil.isNotEmpty(ruleOp)){ - if (allRuleIDlist.size()==0){ + //是否有数据过滤查询 + if (StringUtil.isNotEmpty(ruleOp)) { + if (allRuleIDlist.size() == 0) { allRuleIDlist.add("jnpfNullList"); } List finalAllRuleIDlist = allRuleIDlist; - yysUnitInformationQueryWrapper.lambda().and(t->t.in(YysUnitInformationEntity::getId, finalAllRuleIDlist)); + yysUnitInformationQueryWrapper.lambda().and(t -> t.in(YysUnitInformationEntity::getId, finalAllRuleIDlist)); } //排序 - if(StringUtil.isEmpty(yysUnitInformationPagination.getSidx())){ + if (StringUtil.isEmpty(yysUnitInformationPagination.getSidx())) { yysUnitInformationQueryWrapper.lambda().orderByDesc(YysUnitInformationEntity::getId); - }else{ + } else { try { String sidx = yysUnitInformationPagination.getSidx(); - String[] strs= sidx.split("_name"); + String[] strs = sidx.split("_name"); YysUnitInformationEntity yysUnitInformationEntity = new YysUnitInformationEntity(); Field declaredField = yysUnitInformationEntity.getClass().getDeclaredField(strs[0]); declaredField.setAccessible(true); String value = declaredField.getAnnotation(TableField.class).value(); - yysUnitInformationQueryWrapper="asc".equals(yysUnitInformationPagination.getSort().toLowerCase())?yysUnitInformationQueryWrapper.orderByAsc(value):yysUnitInformationQueryWrapper.orderByDesc(value); + yysUnitInformationQueryWrapper = "asc".equals(yysUnitInformationPagination.getSort().toLowerCase()) ? yysUnitInformationQueryWrapper.orderByAsc(value) : yysUnitInformationQueryWrapper.orderByDesc(value); } catch (NoSuchFieldException e) { e.printStackTrace(); } } - if("0".equals(dataType)){ - if((total>0 && AllIdList.size()>0) || total==0){ - Page page=new Page<>(yysUnitInformationPagination.getCurrentPage(), yysUnitInformationPagination.getPageSize()); - IPage userIPage=this.page(page, yysUnitInformationQueryWrapper); - return yysUnitInformationPagination.setData(userIPage.getRecords(),userIPage.getTotal()); - }else{ + if ("0".equals(dataType)) { + if ((total > 0 && AllIdList.size() > 0) || total == 0) { + Page page = new Page<>(yysUnitInformationPagination.getCurrentPage(), yysUnitInformationPagination.getPageSize()); + IPage userIPage = this.page(page, yysUnitInformationQueryWrapper); + return yysUnitInformationPagination.setData(userIPage.getRecords(), userIPage.getTotal()); + } else { List list = new ArrayList(); return yysUnitInformationPagination.setData(list, list.size()); } - }else{ + } else { return this.list(yysUnitInformationQueryWrapper); } } + @Override - public YysUnitInformationEntity getInfo(String id){ - QueryWrapper queryWrapper=new QueryWrapper<>(); - queryWrapper.lambda().eq(YysUnitInformationEntity::getId,id); + public YysUnitInformationEntity getInfo(String id) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(YysUnitInformationEntity::getId, id); return this.getOne(queryWrapper); } + @Override - public void create(YysUnitInformationEntity entity){ + public void create(YysUnitInformationEntity entity) { this.save(entity); } + @Override - public boolean update(String id, YysUnitInformationEntity entity){ + public boolean update(String id, YysUnitInformationEntity entity) { return this.updateById(entity); } + @Override - public void delete(YysUnitInformationEntity entity){ - if(entity!=null){ + public void delete(YysUnitInformationEntity entity) { + if (entity != null) { this.removeById(entity.getId()); } } - /** 验证表单唯一字段,正则,非空 i-0新增-1修改*/ + + /** + * 验证表单唯一字段,正则,非空 i-0新增-1修改 + */ @Override - public String checkForm(YysUnitInformationForm form,int i) { - boolean isUp =StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0"); - String id=""; + public String checkForm(YysUnitInformationForm form, int i) { + boolean isUp = StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0"); + String id = ""; String countRecover = ""; - if (isUp){ + if (isUp) { id = form.getId(); } //主表字段验证 return countRecover; } + /** - * 新增修改数据(事务回滚) - * @param id - * @param yysUnitInformationForm - * @return - */ + * 新增修改数据(事务回滚) + * + * @param id + * @return + */ @Override @Transactional - public void saveOrUpdate(YysUnitInformationForm yysUnitInformationForm,String id, boolean isSave) throws Exception{ - UserInfo userInfo=userProvider.get(); + public void saveOrUpdate(YysUnitInformationForm yysUnitInformationForm, String id, boolean isSave) throws Exception { + UserInfo userInfo = userProvider.get(); UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId()); yysUnitInformationForm = JsonUtil.getJsonToBean( - generaterSwapUtil.swapDatetime(YysUnitInformationConstant.getFormData(),yysUnitInformationForm),YysUnitInformationForm.class); + generaterSwapUtil.swapDatetime(YysUnitInformationConstant.getFormData(), yysUnitInformationForm), YysUnitInformationForm.class); YysUnitInformationEntity entity = JsonUtil.getJsonToBean(yysUnitInformationForm, YysUnitInformationEntity.class); - if(isSave){ - String mainId = RandomUtil.uuId() ; + if (isSave) { + String mainId = RandomUtil.uuId(); entity.setId(mainId); - }else{ + } else { } this.saveOrUpdate(entity); } + + @Override + @DS("slave_2") + public String syncUnit() { + RowMapper rowMapper = new BeanPropertyRowMapper<>(UnitInfoSync.class); + String sql = "select * from dbo.ComputationUnit"; + List query = this.jdbcTemplate.query(sql, rowMapper); + if (org.apache.commons.collections4.CollectionUtils.isEmpty(query)) { + return "远程单位信息为空"; + } + //过滤出同步过的 + List list = this.list(new LambdaQueryWrapper<>(YysUnitInformationEntity.class).isNull(YysUnitInformationEntity::getDeleteMark)) + .stream().map(YysUnitInformationEntity::getUnitId).collect(Collectors.toList()); + List result = Lists.newArrayList(); + for (UnitInfoSync sync : query) { + if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(list) && list.contains(sync.getCComunitCode())) { + continue; + } + YysUnitInformationEntity entity = new YysUnitInformationEntity(); + String mainId = RandomUtil.uuId(); + entity.setId(mainId); + entity.setUnitId(sync.getCComunitCode()); + entity.setUnitName(sync.getCComUnitName()); + entity.setGroupCode(sync.getCGroupCode()); + entity.setEnableStatus("1"); + result.add(entity); + } + if (CollectionUtils.isEmpty(result)) { + return "没有需要同步的数据"; + } + boolean b = this.saveBatch(result); + if (b) { + return "同步成功"; + } + return "同步失败"; + } } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysMaterialClassController.java b/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysMaterialClassController.java index e3d2ea4..9f4e1d7 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysMaterialClassController.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysMaterialClassController.java @@ -187,4 +187,14 @@ public class YysMaterialClassController { return ActionResult.success(yysMaterialClassMap); } + @Operation(summary = "U8-获取物料分类信息") + @GetMapping("/syncMaterialClass") + public ActionResult syncMaterialClass() { + String result = yysMaterialClassService.syncMaterialClass(); + if (result.contains("成功")) { + return ActionResult.success(result); + } + return ActionResult.fail(result); + } + } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysMaterialInformationController.java b/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysMaterialInformationController.java index d3447ac..c70ce88 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysMaterialInformationController.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysMaterialInformationController.java @@ -1,36 +1,33 @@ package jnpf.controller; -import cn.hutool.core.util.ObjectUtil; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jnpf.base.ActionResult; -import jnpf.base.UserInfo; -import jnpf.exception.DataException; -import jnpf.permission.entity.UserEntity; -import jnpf.service.*; -import jnpf.entity.*; -import jnpf.util.*; -import jnpf.model.yysmaterialinformation.*; +import jnpf.base.vo.PageListVO; +import jnpf.base.vo.PaginationVO; +import jnpf.entity.YysMaterialInformationEntity; +import jnpf.model.yysmaterialinformation.YysMaterialInformationConstant; +import jnpf.model.yysmaterialinformation.YysMaterialInformationForm; +import jnpf.model.yysmaterialinformation.YysMaterialInformationPagination; +import jnpf.service.YysMaterialInformationService; +import jnpf.util.GeneraterSwapUtil; +import jnpf.util.JsonUtil; +import jnpf.util.StringUtil; +import jnpf.util.UserProvider; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; + import javax.validation.Valid; -import java.util.*; -import jnpf.annotation.JnpfField; -import jnpf.base.vo.PageListVO; -import jnpf.base.vo.PaginationVO; -import jnpf.base.vo.DownloadVO; -import jnpf.config.ConfigValueUtil; -import jnpf.base.entity.ProvinceEntity; import java.io.IOException; -import java.util.stream.Collectors; -import jnpf.engine.entity.FlowTaskEntity; -import jnpf.exception.WorkFlowException; -import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; /** * yysMaterialInformation + * * @版本: V3.5 * @版权: 引迈信息技术有限公司(https://www.jnpfsoft.com) * @作者: JNPF开发平台组 @@ -38,7 +35,7 @@ import org.springframework.transaction.annotation.Transactional; */ @Slf4j @RestController -@Tag(name = "yysMaterialInformation" , description = "example") +@Tag(name = "yysMaterialInformation", description = "example") @RequestMapping("/api/example/YysMaterialInformation") public class YysMaterialInformationController { @@ -52,27 +49,26 @@ public class YysMaterialInformationController { private YysMaterialInformationService yysMaterialInformationService; - /** - * 列表 - * - * @param yysMaterialInformationPagination - * @return - */ + * 列表 + * + * @param yysMaterialInformationPagination + * @return + */ @Operation(summary = "获取列表") @PostMapping("/getList") - public ActionResult list(@RequestBody YysMaterialInformationPagination yysMaterialInformationPagination)throws IOException{ - List list= yysMaterialInformationService.getList(yysMaterialInformationPagination); - List> realList=new ArrayList<>(); + public ActionResult list(@RequestBody YysMaterialInformationPagination yysMaterialInformationPagination) throws IOException { + List list = yysMaterialInformationService.getList(yysMaterialInformationPagination); + List> realList = new ArrayList<>(); for (YysMaterialInformationEntity entity : list) { - Map yysMaterialInformationMap=JsonUtil.entityToMap(entity); - yysMaterialInformationMap.put("id", yysMaterialInformationMap.get("id")); - //副表数据 - //子表数据 + Map yysMaterialInformationMap = JsonUtil.entityToMap(entity); + yysMaterialInformationMap.put("id", yysMaterialInformationMap.get("id")); + //副表数据 + //子表数据 realList.add(yysMaterialInformationMap); } //数据转换 - realList = generaterSwapUtil.swapDataList(realList, YysMaterialInformationConstant.getFormData(), YysMaterialInformationConstant.getColumnData(), yysMaterialInformationPagination.getModuleId(),false); + realList = generaterSwapUtil.swapDataList(realList, YysMaterialInformationConstant.getFormData(), YysMaterialInformationConstant.getColumnData(), yysMaterialInformationPagination.getModuleId(), false); //返回对象 PageListVO vo = new PageListVO(); @@ -81,110 +77,128 @@ public class YysMaterialInformationController { vo.setPagination(page); return ActionResult.success(vo); } + /** - * 创建 - * - * @param yysMaterialInformationForm - * @return - */ + * 创建 + * + * @param yysMaterialInformationForm + * @return + */ @PostMapping() @Operation(summary = "创建") public ActionResult create(@RequestBody @Valid YysMaterialInformationForm yysMaterialInformationForm) { - String b = yysMaterialInformationService.checkForm(yysMaterialInformationForm,0); - if (StringUtil.isNotEmpty(b)){ - return ActionResult.fail(b ); + String b = yysMaterialInformationService.checkForm(yysMaterialInformationForm, 0); + if (StringUtil.isNotEmpty(b)) { + return ActionResult.fail(b); } - try{ - yysMaterialInformationService.saveOrUpdate(yysMaterialInformationForm, null ,true); - }catch(Exception e){ + try { + yysMaterialInformationService.saveOrUpdate(yysMaterialInformationForm, null, true); + } catch (Exception e) { return ActionResult.fail("新增数据失败"); } return ActionResult.success("创建成功"); } + /** - * 编辑 - * @param id - * @param yysMaterialInformationForm - * @return - */ + * 编辑 + * + * @param id + * @param yysMaterialInformationForm + * @return + */ @PutMapping("/{id}") @Operation(summary = "更新") - public ActionResult update(@PathVariable("id") String id,@RequestBody @Valid YysMaterialInformationForm yysMaterialInformationForm, - @RequestParam(value = "isImport", required = false) boolean isImport){ + public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid YysMaterialInformationForm yysMaterialInformationForm, + @RequestParam(value = "isImport", required = false) boolean isImport) { yysMaterialInformationForm.setId(id); if (!isImport) { - String b = yysMaterialInformationService.checkForm(yysMaterialInformationForm,1); - if (StringUtil.isNotEmpty(b)){ - return ActionResult.fail(b ); + String b = yysMaterialInformationService.checkForm(yysMaterialInformationForm, 1); + if (StringUtil.isNotEmpty(b)) { + return ActionResult.fail(b); } } - YysMaterialInformationEntity entity= yysMaterialInformationService.getInfo(id); - if(entity!=null){ - try{ - yysMaterialInformationService.saveOrUpdate(yysMaterialInformationForm,id,false); - }catch(Exception e){ + YysMaterialInformationEntity entity = yysMaterialInformationService.getInfo(id); + if (entity != null) { + try { + yysMaterialInformationService.saveOrUpdate(yysMaterialInformationForm, id, false); + } catch (Exception e) { return ActionResult.fail("修改数据失败"); } return ActionResult.success("更新成功"); - }else{ + } else { return ActionResult.fail("更新失败,数据不存在"); } } + /** - * 删除 - * @param id - * @return - */ + * 删除 + * + * @param id + * @return + */ @Operation(summary = "删除") @DeleteMapping("/{id}") @Transactional - public ActionResult delete(@PathVariable("id") String id){ - YysMaterialInformationEntity entity= yysMaterialInformationService.getInfo(id); - if(entity!=null){ + public ActionResult delete(@PathVariable("id") String id) { + YysMaterialInformationEntity entity = yysMaterialInformationService.getInfo(id); + if (entity != null) { //主表数据删除 yysMaterialInformationService.delete(entity); } return ActionResult.success("删除成功"); } + /** - * 表单信息(详情页) - * 详情页面使用-转换数据 - * @param id - * @return - */ + * 表单信息(详情页) + * 详情页面使用-转换数据 + * + * @param id + * @return + */ @Operation(summary = "表单信息(详情页)") @GetMapping("/detail/{id}") - public ActionResult detailInfo(@PathVariable("id") String id){ - YysMaterialInformationEntity entity= yysMaterialInformationService.getInfo(id); - if(entity==null){ + public ActionResult detailInfo(@PathVariable("id") String id) { + YysMaterialInformationEntity entity = yysMaterialInformationService.getInfo(id); + if (entity == null) { return ActionResult.fail("表单数据不存在!"); } - Map yysMaterialInformationMap=JsonUtil.entityToMap(entity); + Map yysMaterialInformationMap = JsonUtil.entityToMap(entity); yysMaterialInformationMap.put("id", yysMaterialInformationMap.get("id")); //副表数据 //子表数据 - yysMaterialInformationMap = generaterSwapUtil.swapDataDetail(yysMaterialInformationMap,YysMaterialInformationConstant.getFormData(),"591246118818418565",false); + yysMaterialInformationMap = generaterSwapUtil.swapDataDetail(yysMaterialInformationMap, YysMaterialInformationConstant.getFormData(), "591246118818418565", false); return ActionResult.success(yysMaterialInformationMap); } + /** - * 获取详情(编辑页) - * 编辑页面使用-不转换数据 - * @param id - * @return - */ + * 获取详情(编辑页) + * 编辑页面使用-不转换数据 + * + * @param id + * @return + */ @Operation(summary = "信息") @GetMapping("/{id}") - public ActionResult info(@PathVariable("id") String id){ - YysMaterialInformationEntity entity= yysMaterialInformationService.getInfo(id); - if(entity==null){ + public ActionResult info(@PathVariable("id") String id) { + YysMaterialInformationEntity entity = yysMaterialInformationService.getInfo(id); + if (entity == null) { return ActionResult.fail("表单数据不存在!"); } - Map yysMaterialInformationMap=JsonUtil.entityToMap(entity); + Map yysMaterialInformationMap = JsonUtil.entityToMap(entity); yysMaterialInformationMap.put("id", yysMaterialInformationMap.get("id")); //副表数据 //子表数据 - yysMaterialInformationMap = generaterSwapUtil.swapDataForm(yysMaterialInformationMap,YysMaterialInformationConstant.getFormData(),YysMaterialInformationConstant.TABLEFIELDKEY,YysMaterialInformationConstant.TABLERENAMES); + yysMaterialInformationMap = generaterSwapUtil.swapDataForm(yysMaterialInformationMap, YysMaterialInformationConstant.getFormData(), YysMaterialInformationConstant.TABLEFIELDKEY, YysMaterialInformationConstant.TABLERENAMES); return ActionResult.success(yysMaterialInformationMap); } + @Operation(summary = "U8-获取物料信息") + @GetMapping("/syncMaterialInfo") + public ActionResult syncMaterialInfo() { + String result = yysMaterialInformationService.syncMaterialInfo(); + if (result.contains("成功")) { + return ActionResult.success(result); + } + return ActionResult.fail(result); + } } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysSupplierClassController.java b/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysSupplierClassController.java index 762fdde..779d1c1 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysSupplierClassController.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysSupplierClassController.java @@ -1,33 +1,29 @@ package jnpf.controller; -import cn.hutool.core.util.ObjectUtil; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jnpf.base.ActionResult; -import jnpf.base.UserInfo; -import jnpf.exception.DataException; -import jnpf.permission.entity.UserEntity; -import jnpf.service.*; -import jnpf.entity.*; -import jnpf.util.*; -import jnpf.model.yyssupplierclass.*; +import jnpf.base.vo.PageListVO; +import jnpf.base.vo.PaginationVO; +import jnpf.entity.YysSupplierClassEntity; +import jnpf.model.yyssupplierclass.YysSupplierClassConstant; +import jnpf.model.yyssupplierclass.YysSupplierClassForm; +import jnpf.model.yyssupplierclass.YysSupplierClassPagination; +import jnpf.service.YysSupplierClassService; +import jnpf.util.GeneraterSwapUtil; +import jnpf.util.JsonUtil; +import jnpf.util.StringUtil; +import jnpf.util.UserProvider; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; + import javax.validation.Valid; -import java.util.*; -import jnpf.annotation.JnpfField; -import jnpf.base.vo.PageListVO; -import jnpf.base.vo.PaginationVO; -import jnpf.base.vo.DownloadVO; -import jnpf.config.ConfigValueUtil; -import jnpf.base.entity.ProvinceEntity; import java.io.IOException; -import java.util.stream.Collectors; -import jnpf.engine.entity.FlowTaskEntity; -import jnpf.exception.WorkFlowException; -import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; /** * yysSupplierClass @@ -187,4 +183,14 @@ public class YysSupplierClassController { return ActionResult.success(yysSupplierClassMap); } + @Operation(summary = "U8-获取供应商分类") + @GetMapping("/syncSupplierClass") + public ActionResult syncSupplierClass() { + String result = yysSupplierClassService.syncSupplierClass(); + if (result.contains("成功")) { + return ActionResult.success(result); + } + return ActionResult.fail(result); + } + } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysSupplierInformationController.java b/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysSupplierInformationController.java index 7967cd1..1e50a3b 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysSupplierInformationController.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysSupplierInformationController.java @@ -200,10 +200,14 @@ public class YysSupplierInformationController { return ActionResult.success(yysSupplierInformationMap); } - @Operation(summary = "测试连接sqlserver数据库返回数据") - @GetMapping("/test") - public ActionResult test() { - return ActionResult.success(yysSupplierInformationService.test()); + @Operation(summary = "U8-获取供应商信息") + @GetMapping("/syncSupplier") + public ActionResult syncSupplier() { + String result = yysSupplierInformationService.syncSupplier(); + if (result.contains("成功")) { + return ActionResult.success(result); + } + return ActionResult.fail(result); } } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysUnitInformationController.java b/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysUnitInformationController.java index 80ac31c..bbac7fb 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysUnitInformationController.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/YysUnitInformationController.java @@ -15,22 +15,27 @@ import jnpf.model.yysunitinformation.*; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; + import javax.validation.Valid; import java.util.*; + import jnpf.annotation.JnpfField; import jnpf.base.vo.PageListVO; import jnpf.base.vo.PaginationVO; import jnpf.base.vo.DownloadVO; import jnpf.config.ConfigValueUtil; import jnpf.base.entity.ProvinceEntity; + import java.io.IOException; import java.util.stream.Collectors; + import jnpf.engine.entity.FlowTaskEntity; import jnpf.exception.WorkFlowException; import org.springframework.transaction.annotation.Transactional; /** * yysUnitInformation + * * @版本: V3.5 * @版权: 引迈信息技术有限公司(https://www.jnpfsoft.com) * @作者: JNPF开发平台组 @@ -38,7 +43,7 @@ import org.springframework.transaction.annotation.Transactional; */ @Slf4j @RestController -@Tag(name = "yysUnitInformation" , description = "example") +@Tag(name = "yysUnitInformation", description = "example") @RequestMapping("/api/example/YysUnitInformation") public class YysUnitInformationController { @@ -52,27 +57,26 @@ public class YysUnitInformationController { private YysUnitInformationService yysUnitInformationService; - /** - * 列表 - * - * @param yysUnitInformationPagination - * @return - */ + * 列表 + * + * @param yysUnitInformationPagination + * @return + */ @Operation(summary = "获取列表") @PostMapping("/getList") - public ActionResult list(@RequestBody YysUnitInformationPagination yysUnitInformationPagination)throws IOException{ - List list= yysUnitInformationService.getList(yysUnitInformationPagination); - List> realList=new ArrayList<>(); + public ActionResult list(@RequestBody YysUnitInformationPagination yysUnitInformationPagination) throws IOException { + List list = yysUnitInformationService.getList(yysUnitInformationPagination); + List> realList = new ArrayList<>(); for (YysUnitInformationEntity entity : list) { - Map yysUnitInformationMap=JsonUtil.entityToMap(entity); - yysUnitInformationMap.put("id", yysUnitInformationMap.get("id")); - //副表数据 - //子表数据 + Map yysUnitInformationMap = JsonUtil.entityToMap(entity); + yysUnitInformationMap.put("id", yysUnitInformationMap.get("id")); + //副表数据 + //子表数据 realList.add(yysUnitInformationMap); } //数据转换 - realList = generaterSwapUtil.swapDataList(realList, YysUnitInformationConstant.getFormData(), YysUnitInformationConstant.getColumnData(), yysUnitInformationPagination.getModuleId(),false); + realList = generaterSwapUtil.swapDataList(realList, YysUnitInformationConstant.getFormData(), YysUnitInformationConstant.getColumnData(), yysUnitInformationPagination.getModuleId(), false); //返回对象 PageListVO vo = new PageListVO(); @@ -81,110 +85,129 @@ public class YysUnitInformationController { vo.setPagination(page); return ActionResult.success(vo); } + /** - * 创建 - * - * @param yysUnitInformationForm - * @return - */ + * 创建 + * + * @param yysUnitInformationForm + * @return + */ @PostMapping() @Operation(summary = "创建") public ActionResult create(@RequestBody @Valid YysUnitInformationForm yysUnitInformationForm) { - String b = yysUnitInformationService.checkForm(yysUnitInformationForm,0); - if (StringUtil.isNotEmpty(b)){ - return ActionResult.fail(b ); + String b = yysUnitInformationService.checkForm(yysUnitInformationForm, 0); + if (StringUtil.isNotEmpty(b)) { + return ActionResult.fail(b); } - try{ - yysUnitInformationService.saveOrUpdate(yysUnitInformationForm, null ,true); - }catch(Exception e){ + try { + yysUnitInformationService.saveOrUpdate(yysUnitInformationForm, null, true); + } catch (Exception e) { return ActionResult.fail("新增数据失败"); } return ActionResult.success("创建成功"); } + /** - * 编辑 - * @param id - * @param yysUnitInformationForm - * @return - */ + * 编辑 + * + * @param id + * @param yysUnitInformationForm + * @return + */ @PutMapping("/{id}") @Operation(summary = "更新") - public ActionResult update(@PathVariable("id") String id,@RequestBody @Valid YysUnitInformationForm yysUnitInformationForm, - @RequestParam(value = "isImport", required = false) boolean isImport){ + public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid YysUnitInformationForm yysUnitInformationForm, + @RequestParam(value = "isImport", required = false) boolean isImport) { yysUnitInformationForm.setId(id); if (!isImport) { - String b = yysUnitInformationService.checkForm(yysUnitInformationForm,1); - if (StringUtil.isNotEmpty(b)){ - return ActionResult.fail(b ); + String b = yysUnitInformationService.checkForm(yysUnitInformationForm, 1); + if (StringUtil.isNotEmpty(b)) { + return ActionResult.fail(b); } } - YysUnitInformationEntity entity= yysUnitInformationService.getInfo(id); - if(entity!=null){ - try{ - yysUnitInformationService.saveOrUpdate(yysUnitInformationForm,id,false); - }catch(Exception e){ + YysUnitInformationEntity entity = yysUnitInformationService.getInfo(id); + if (entity != null) { + try { + yysUnitInformationService.saveOrUpdate(yysUnitInformationForm, id, false); + } catch (Exception e) { return ActionResult.fail("修改数据失败"); } return ActionResult.success("更新成功"); - }else{ + } else { return ActionResult.fail("更新失败,数据不存在"); } } + /** - * 删除 - * @param id - * @return - */ + * 删除 + * + * @param id + * @return + */ @Operation(summary = "删除") @DeleteMapping("/{id}") @Transactional - public ActionResult delete(@PathVariable("id") String id){ - YysUnitInformationEntity entity= yysUnitInformationService.getInfo(id); - if(entity!=null){ + public ActionResult delete(@PathVariable("id") String id) { + YysUnitInformationEntity entity = yysUnitInformationService.getInfo(id); + if (entity != null) { //主表数据删除 yysUnitInformationService.delete(entity); } return ActionResult.success("删除成功"); } + /** - * 表单信息(详情页) - * 详情页面使用-转换数据 - * @param id - * @return - */ + * 表单信息(详情页) + * 详情页面使用-转换数据 + * + * @param id + * @return + */ @Operation(summary = "表单信息(详情页)") @GetMapping("/detail/{id}") - public ActionResult detailInfo(@PathVariable("id") String id){ - YysUnitInformationEntity entity= yysUnitInformationService.getInfo(id); - if(entity==null){ + public ActionResult detailInfo(@PathVariable("id") String id) { + YysUnitInformationEntity entity = yysUnitInformationService.getInfo(id); + if (entity == null) { return ActionResult.fail("表单数据不存在!"); } - Map yysUnitInformationMap=JsonUtil.entityToMap(entity); + Map yysUnitInformationMap = JsonUtil.entityToMap(entity); yysUnitInformationMap.put("id", yysUnitInformationMap.get("id")); //副表数据 //子表数据 - yysUnitInformationMap = generaterSwapUtil.swapDataDetail(yysUnitInformationMap,YysUnitInformationConstant.getFormData(),"591253620058492869",false); + yysUnitInformationMap = generaterSwapUtil.swapDataDetail(yysUnitInformationMap, YysUnitInformationConstant.getFormData(), "591253620058492869", false); return ActionResult.success(yysUnitInformationMap); } + /** - * 获取详情(编辑页) - * 编辑页面使用-不转换数据 - * @param id - * @return - */ + * 获取详情(编辑页) + * 编辑页面使用-不转换数据 + * + * @param id + * @return + */ @Operation(summary = "信息") @GetMapping("/{id}") - public ActionResult info(@PathVariable("id") String id){ - YysUnitInformationEntity entity= yysUnitInformationService.getInfo(id); - if(entity==null){ + public ActionResult info(@PathVariable("id") String id) { + YysUnitInformationEntity entity = yysUnitInformationService.getInfo(id); + if (entity == null) { return ActionResult.fail("表单数据不存在!"); } - Map yysUnitInformationMap=JsonUtil.entityToMap(entity); + Map yysUnitInformationMap = JsonUtil.entityToMap(entity); yysUnitInformationMap.put("id", yysUnitInformationMap.get("id")); //副表数据 //子表数据 - yysUnitInformationMap = generaterSwapUtil.swapDataForm(yysUnitInformationMap,YysUnitInformationConstant.getFormData(),YysUnitInformationConstant.TABLEFIELDKEY,YysUnitInformationConstant.TABLERENAMES); + yysUnitInformationMap = generaterSwapUtil.swapDataForm(yysUnitInformationMap, YysUnitInformationConstant.getFormData(), YysUnitInformationConstant.TABLEFIELDKEY, YysUnitInformationConstant.TABLERENAMES); return ActionResult.success(yysUnitInformationMap); } + @Operation(summary = "U8-获取单位信息") + @GetMapping("/syncUnit") + public ActionResult syncUnit() { + String result = yysUnitInformationService.syncUnit(); + if (result.contains("成功")) { + return ActionResult.success(result); + } + return ActionResult.fail(result); + } + } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysUnitInformationEntity.java b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysUnitInformationEntity.java index 4e13966..f0c2926 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysUnitInformationEntity.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/YysUnitInformationEntity.java @@ -20,6 +20,8 @@ public class YysUnitInformationEntity { private String unitId; @TableField(value = "UNIT_NAME" , updateStrategy = FieldStrategy.IGNORED) private String unitName; + @TableField(value = "GROUP_NAME" , updateStrategy = FieldStrategy.IGNORED) + private String groupCode; @TableField(value = "ENABLE_STATUS" , updateStrategy = FieldStrategy.IGNORED) private String enableStatus; @TableField("REAMRK") diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yysmaterialclass/MaterialClassSync.java b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yysmaterialclass/MaterialClassSync.java new file mode 100644 index 0000000..1438f57 --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yysmaterialclass/MaterialClassSync.java @@ -0,0 +1,26 @@ +package jnpf.model.yysmaterialclass; + +import lombok.Data; + +@Data +public class MaterialClassSync { + + /** + * 物料分类编码 + */ + private String cInvCCode; + + /** + * 物料名称 + */ + private String cInvCName; + /** + * 分类等级 + */ + private boolean iInvCGrade; + + /** + * 不知道啥意思 + */ + private String bInvCEnd; +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yysmaterialinformation/MaterialInformationSync.java b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yysmaterialinformation/MaterialInformationSync.java new file mode 100644 index 0000000..a56a0f7 --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yysmaterialinformation/MaterialInformationSync.java @@ -0,0 +1,36 @@ +package jnpf.model.yysmaterialinformation; + +import lombok.Data; + +@Data +public class MaterialInformationSync { + /** + * 物料编码 + */ + private String cInvCode; + + /** + * 物料简称 + */ + private String cInvAddCode; + + /** + * 物料名称 + */ + private String cInvName; + + /** + * 物料分类 + */ + private String cInvCCode; + + /** + * 物料供应商(我猜的) + */ + private String cVenCode; + + /** + * 安全库存 + */ + private String iSafeNum; +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yyssupplierclass/SupplierClassSync.java b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yyssupplierclass/SupplierClassSync.java new file mode 100644 index 0000000..144bd2b --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yyssupplierclass/SupplierClassSync.java @@ -0,0 +1,27 @@ +package jnpf.model.yyssupplierclass; + +import lombok.Data; + +@Data +public class SupplierClassSync { + + /** + * 供应商分类 + **/ + private String cVCCode; + + /** + * 分类名称 + */ + private String cVCName; + + /** + * 分类等级 + */ + private boolean iVCGrade; + + /** + * 不知道啥意思 + */ + private String bVCEnd; +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yyssupplierinformation/SupplierInfoSync.java b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yyssupplierinformation/SupplierInfoSync.java new file mode 100644 index 0000000..b5e900a --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yyssupplierinformation/SupplierInfoSync.java @@ -0,0 +1,27 @@ +package jnpf.model.yyssupplierinformation; + +import lombok.Data; + +@Data +public class SupplierInfoSync { + + /** + * 供应商编码 + */ + private String cVenCode; + + /** + * 供应商名称 + */ + private String cVenName; + + /** + * 供应商简称 + */ + private String cVenAbbName; + + /** + * 供应商分类、供应商启用状态 + **/ + private String cVCCode; +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yysunitinformation/UnitInfoSync.java b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yysunitinformation/UnitInfoSync.java new file mode 100644 index 0000000..e41bab4 --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/yysunitinformation/UnitInfoSync.java @@ -0,0 +1,19 @@ +package jnpf.model.yysunitinformation; + +import lombok.Data; + +@Data +public class UnitInfoSync { + /** + * 单位编码 + */ + private String cComunitCode; + /** + * 单位名称 + */ + private String cComUnitName; + /** + * 单位组编码 + */ + private String cGroupCode; +} diff --git a/jnpf-java-boot/jnpf-web/src/views/yys/yysinventoryquery/index.vue b/jnpf-java-boot/jnpf-web/src/views/yys/yysinventoryquery/index.vue index 0edd14a..afd0dda 100644 --- a/jnpf-java-boot/jnpf-web/src/views/yys/yysinventoryquery/index.vue +++ b/jnpf-java-boot/jnpf-web/src/views/yys/yysinventoryquery/index.vue @@ -31,6 +31,8 @@
+ 获取数据 +
diff --git a/jnpf-java-boot/jnpf-web/src/views/yys/yysmaterialclass/index.vue b/jnpf-java-boot/jnpf-web/src/views/yys/yysmaterialclass/index.vue index 5cc7593..4f2a4a1 100644 --- a/jnpf-java-boot/jnpf-web/src/views/yys/yysmaterialclass/index.vue +++ b/jnpf-java-boot/jnpf-web/src/views/yys/yysmaterialclass/index.vue @@ -31,6 +31,8 @@
新增 + 获取数据 +
@@ -172,6 +174,25 @@ export default { this.queryData = JSON.parse(JSON.stringify(this.query)) }, methods: { + syncData(){ + this.$confirm('此操作将从远程库中拉取同步数据, 是否继续?', '提示', { + type: 'warning' + }).then(() => { + request({ + url: `/api/example/YysMaterialClass/syncMaterialClass`, + method: 'GET' + }).then(res => { + this.$message({ + type: 'success', + message: res.msg, + onClose: () => { + this.initData() + } + }); + }) + }).catch(() => { + }); + }, toDetail(defaultValue, modelId) { if (!defaultValue) return getConfigData(modelId).then(res => { diff --git a/jnpf-java-boot/jnpf-web/src/views/yys/yysmaterialinformation/index.vue b/jnpf-java-boot/jnpf-web/src/views/yys/yysmaterialinformation/index.vue index 033f93a..bb77ea2 100644 --- a/jnpf-java-boot/jnpf-web/src/views/yys/yysmaterialinformation/index.vue +++ b/jnpf-java-boot/jnpf-web/src/views/yys/yysmaterialinformation/index.vue @@ -44,6 +44,8 @@
新增 + 获取数据 +
@@ -195,6 +197,25 @@ export default { this.queryData = JSON.parse(JSON.stringify(this.query)) }, methods: { + syncData(){ + this.$confirm('此操作将从远程库中拉取同步数据, 是否继续?', '提示', { + type: 'warning' + }).then(() => { + request({ + url: `/api/example/YysMaterialInformation/syncMaterialInfo`, + method: 'GET' + }).then(res => { + this.$message({ + type: 'success', + message: res.msg, + onClose: () => { + this.initData() + } + }); + }) + }).catch(() => { + }); + }, toDetail(defaultValue, modelId) { if (!defaultValue) return getConfigData(modelId).then(res => { diff --git a/jnpf-java-boot/jnpf-web/src/views/yys/yyssupplierclass/index.vue b/jnpf-java-boot/jnpf-web/src/views/yys/yyssupplierclass/index.vue index 12121e5..3009f8e 100644 --- a/jnpf-java-boot/jnpf-web/src/views/yys/yyssupplierclass/index.vue +++ b/jnpf-java-boot/jnpf-web/src/views/yys/yyssupplierclass/index.vue @@ -31,6 +31,8 @@
新增 + 获取数据 +
@@ -172,6 +174,25 @@ export default { this.queryData = JSON.parse(JSON.stringify(this.query)) }, methods: { + syncData(){ + this.$confirm('此操作将从远程库中拉取同步数据, 是否继续?', '提示', { + type: 'warning' + }).then(() => { + request({ + url: `/api/example/YysSupplierClass/syncSupplierClass`, + method: 'GET' + }).then(res => { + this.$message({ + type: 'success', + message: res.msg, + onClose: () => { + this.initData() + } + }); + }) + }).catch(() => { + }); + }, toDetail(defaultValue, modelId) { if (!defaultValue) return getConfigData(modelId).then(res => { diff --git a/jnpf-java-boot/jnpf-web/src/views/yys/yyssupplierinformation/index.vue b/jnpf-java-boot/jnpf-web/src/views/yys/yyssupplierinformation/index.vue index 914383d..b316c59 100644 --- a/jnpf-java-boot/jnpf-web/src/views/yys/yyssupplierinformation/index.vue +++ b/jnpf-java-boot/jnpf-web/src/views/yys/yyssupplierinformation/index.vue @@ -31,6 +31,8 @@
新增 + 获取数据 +
@@ -364,6 +366,25 @@ export default { this.listLoading = false }) }, + syncData(){ + this.$confirm('此操作将从远程库中拉取同步数据, 是否继续?', '提示', { + type: 'warning' + }).then(() => { + request({ + url: `/api/example/YysSupplierInformation/syncSupplier`, + method: 'GET' + }).then(res => { + this.$message({ + type: 'success', + message: res.msg, + onClose: () => { + this.initData() + } + }); + }) + }).catch(() => { + }); + }, handleDel(id) { this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', { type: 'warning' diff --git a/jnpf-java-boot/jnpf-web/src/views/yys/yysunitinformation/index.vue b/jnpf-java-boot/jnpf-web/src/views/yys/yysunitinformation/index.vue index 0569bbe..37255b7 100644 --- a/jnpf-java-boot/jnpf-web/src/views/yys/yysunitinformation/index.vue +++ b/jnpf-java-boot/jnpf-web/src/views/yys/yysunitinformation/index.vue @@ -26,6 +26,8 @@
新增 + 获取数据 +
@@ -164,6 +166,25 @@ export default { this.queryData = JSON.parse(JSON.stringify(this.query)) }, methods: { + syncData(){ + this.$confirm('此操作将从远程库中拉取同步数据, 是否继续?', '提示', { + type: 'warning' + }).then(() => { + request({ + url: `/api/example/YysUnitInformation/syncUnit`, + method: 'GET' + }).then(res => { + this.$message({ + type: 'success', + message: res.msg, + onClose: () => { + this.initData() + } + }); + }) + }).catch(() => { + }); + }, toDetail(defaultValue, modelId) { if (!defaultValue) return getConfigData(modelId).then(res => {