package com.jilongda.manage; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.jilongda.manage.authority.model.SecResources; import com.jilongda.manage.authority.model.SecRoleResource; import com.jilongda.manage.authority.service.SecResourcesService; import com.jilongda.manage.authority.service.SecRoleResourceService; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; /** * @Description * @Author xiaochen * @Date 2022/6/23/02315:40 */ @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = ManageApplication.class) public class ManageTest { @Autowired public SecResourcesService secResourcesService; @Autowired public SecRoleResourceService secRoleResourceService; @Test public void update() { List secResource = secResourcesService.list(Wrappers.lambdaQuery(SecResources.class) .eq(SecResources::getSort,0)); List collect = secResource.stream().map(SecResources::getId).collect(Collectors.toList()); List list = new ArrayList<>(); for (Long aLong : collect) { SecRoleResource secRoleResource = new SecRoleResource(); secRoleResource.setResourceId(aLong); secRoleResource.setRoleId(1L); list.add(secRoleResource); } secRoleResourceService.saveBatch(list); } @Test public void getMonth() { String data = "{order={invoiceDetail=[{specType=无, taxRate=0.09, unit=次, price=540.20, num=1, withTaxFlag=1, goodsCode=30101020201, goodsName=运输费}, {specType=无, taxRate=0.09, unit=次, price=540.20, num=1, withTaxFlag=1, goodsCode=30101020201, goodsName=运输费}], buyerTel=0571-88391517, salerTel=15275228845, orderNo=INV_24042600085_1, pushMode=0, remark=中国城镇供水排水协会2024年会暨城镇水务技术与产品展示会,ONE_24042100009SXqdz, checker=梁据松, buyerName=杭州诺普泰克仪器仪表有限公司, invoiceDate=2024-04-26 16:02:28, salerAddress=山东省青岛市黄岛区滨海大道7777号中铁博览城N3馆二楼, clerk=张晓华, payee=何越, invoiceGoodsTransports=[{origin=杭州市, destination=青岛市, transportTool=2, transportToolNum=琼A55659,轻型箱式货车, goodsName=机具仪器}, {origin=杭州市, destination=青岛市, transportTool=2, goodsName=机具仪器}], buyerAddress=杭州市余杭区钱江经济开发区顺风路536号10幢201室, buyerPhone=0571-88391517, buyerAccount=联合银行祥符支行 201000006175321, buyerTaxNum=91330100785347679N, extensionNumber=666, salerTaxNum=91370211MA3P7CYH1R, invoiceType=1, invoiceLine=pc, specificFactor=4, email=3232@qq.com}}"; String replace = data.replace("=", "\":\"") .replace(", ","\",\"") .replace("\"{","{") .replace("{","{\"") .replace("}\"","}") .replace("}","\"}") .replace("\"[","[") .replace("]\"","]"); System.err.println(replace); } @Test public void getMonth1() { String data = "{'specType':'无', 'taxRate':'0.09', 'unit':'次', 'price':'540.20', 'num':'1','withTaxFlag':'1', 'goodsCode':'30101020201','goodsName':'运输费'}"; String replace = data.replace("\'", "\""); System.err.println(replace); } }