New file |
| | |
| | | package com.matrix; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import com.matrix.system.common.bean.BusParameterSettings; |
| | | import com.matrix.system.common.bean.SysCompany; |
| | | import com.matrix.system.common.constance.AppConstance; |
| | | import com.matrix.system.common.dao.BusParameterSettingsDao; |
| | | import com.matrix.system.common.dao.SysCompanyDao; |
| | | import com.matrix.system.hive.bean.ParameterSettings; |
| | | import com.matrix.system.hive.dao.ParameterSettingsDao; |
| | | import org.junit.Test; |
| | | import org.junit.runner.RunWith; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | import org.springframework.test.context.junit4.SpringRunner; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 配置工具 |
| | | * |
| | | * @author jiangyouyao |
| | | * @email 512061637@qq.com |
| | | * @date 2019年2月25日 |
| | | */ |
| | | @RunWith(SpringRunner.class) |
| | | @SpringBootTest(classes = {ZqErpApplication.class},webEnvironment =SpringBootTest.WebEnvironment.RANDOM_PORT) |
| | | public class ParameterSettingsTool { |
| | | |
| | | |
| | | @Autowired |
| | | private ParameterSettingsDao parameterSettingsDao; |
| | | |
| | | @Autowired |
| | | private BusParameterSettingsDao busParameterSettingsDao; |
| | | |
| | | @Autowired |
| | | private SysCompanyDao sysCompanyDao; |
| | | |
| | | /* |
| | | 给所有公司加上多个配置,如果已经存在则跳过 |
| | | */ |
| | | @Test |
| | | public void addSettings(){ |
| | | |
| | | List<ParameterSettings> newSettings=new ArrayList<>(); |
| | | |
| | | |
| | | ParameterSettings newSetting1=new ParameterSettings(); |
| | | newSetting1.setCode("APP_BANNER_GL"); |
| | | newSetting1.setName("APP管理模块Banner"); |
| | | newSetting1.setType(1); |
| | | newSetting1.setCategory("APP设置"); |
| | | newSettings.add(newSetting1); |
| | | |
| | | ParameterSettings newSetting2=new ParameterSettings(); |
| | | newSetting2.setCode(AppConstance.WAREHOUSE_MANAGE_STOCK); |
| | | newSetting2.setName("是否管理产品库存"); |
| | | newSetting2.setType(1); |
| | | newSetting2.setCategory("仓库设置"); |
| | | newSettings.add(newSetting2); |
| | | |
| | | ParameterSettings newSetting3=new ParameterSettings(); |
| | | newSetting3.setCode(AppConstance.WECHARPAY_RECHARGE_NOTIFYURL); |
| | | newSetting3.setName("储值卡充值回调地址"); |
| | | newSetting3.setType(1); |
| | | newSetting3.setCategory("微信开发配置"); |
| | | newSettings.add(newSetting3); |
| | | |
| | | ParameterSettings newSetting4=new ParameterSettings(); |
| | | newSetting4.setCode(AppConstance.SHOP_MANAGE_JJCPAS_CONSUME); |
| | | newSetting4.setName("家居产品销售是否生成消耗业绩"); |
| | | newSetting4.setType(1); |
| | | newSetting4.setCategory("店务配置"); |
| | | newSettings.add(newSetting4); |
| | | |
| | | |
| | | |
| | | for (ParameterSettings newSetting : newSettings) { |
| | | List<ParameterSettings> parameterSettings = parameterSettingsDao.selectByModel(newSetting); |
| | | if(CollectionUtil.isEmpty(parameterSettings)){ |
| | | parameterSettingsDao.insert(newSetting); |
| | | System.out.println("新增配置"+newSetting.getName()); |
| | | }else { |
| | | System.out.println("配置"+newSetting.getName()+"已经存在"); |
| | | } |
| | | addSettingsTOAllCompany(newSetting); |
| | | } |
| | | } |
| | | |
| | | private void addSettingsTOAllCompany(ParameterSettings newSetting) { |
| | | |
| | | List<SysCompany> allCompany = sysCompanyDao.selectByModel(null); |
| | | |
| | | for (SysCompany sysCompany : allCompany) { |
| | | BusParameterSettings checkExist = busParameterSettingsDao.selectCompanyParamByCode(newSetting.getCode(), sysCompany.getComId()); |
| | | if(checkExist==null){ |
| | | BusParameterSettings busParameterSettings=new BusParameterSettings(); |
| | | busParameterSettings.setCompanyId(sysCompany.getComId()); |
| | | busParameterSettings.setParamCode(newSetting.getCode()); |
| | | busParameterSettings.setParamValue(""); |
| | | busParameterSettingsDao.insert(busParameterSettings); |
| | | System.out.println(sysCompany.getComName()+"新增成功"); |
| | | }else{ |
| | | System.out.println("公司"+sysCompany.getComName()+"已经存在配置"+newSetting.getName()); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |