diff --git a/youchain-system/src/main/java/com/youchain/EmailValidator.java b/youchain-system/src/main/java/com/youchain/EmailValidator.java new file mode 100644 index 0000000..eed33f0 --- /dev/null +++ b/youchain-system/src/main/java/com/youchain/EmailValidator.java @@ -0,0 +1,26 @@ +package com.youchain; + +import java.util.regex.Pattern; + +public class EmailValidator { + // 正则表达式规则来源于:https://howtodoinjava.com/java/regex/java-email-address-validation-regex/ + private static final String EMAIL_PATTERN = + "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"; + + private static final Pattern pattern = Pattern.compile(EMAIL_PATTERN); + + public static boolean validate(String email) { + if (email == null) { + return false; + } + return pattern.matcher(email).matches(); + } + + public static void main(String[] args) { + // 测试电子邮件格式是否正确 + System.out.println(validate("houjl@youchain56.com")); // true + System.out.println(validate("example.test@sub.test.com")); // true + System.out.println(validate("example.test.com")); // false + System.out.println(validate("example#test@test.com")); // false + } +} \ No newline at end of file diff --git a/youchain-system/src/main/java/com/youchain/basicdata/domain/RuleConfigure.java b/youchain-system/src/main/java/com/youchain/basicdata/domain/RuleConfigure.java new file mode 100644 index 0000000..6248237 --- /dev/null +++ b/youchain-system/src/main/java/com/youchain/basicdata/domain/RuleConfigure.java @@ -0,0 +1,159 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package com.youchain.basicdata.domain; + +import com.youchain.base.BaseEntity; +import lombok.Data; +import cn.hutool.core.bean.BeanUtil; +import io.swagger.annotations.ApiModelProperty; +import cn.hutool.core.bean.copier.CopyOptions; +import javax.persistence.*; +import javax.validation.constraints.*; +import java.sql.Timestamp; +import java.io.Serializable; + +/** +* @website https://eladmin.vip +* @description / +* @author houjianlan +* @date 2024-09-13 +**/ +@Entity +@Data +@Table(name="sys_rule_configure") +public class RuleConfigure extends BaseEntity implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "`id`") + @ApiModelProperty(value = "id") + private Long id; + + @Column(name = "`rule_type`") + @NotBlank + @ApiModelProperty(value = "规则类型") + private String ruleType; + + @Column(name = "`sql_content`") + @NotBlank + @ApiModelProperty(value = "SQL内容") + private String sqlContent; + + @Column(name = "`description`") + @ApiModelProperty(value = "描述") + private String description; + + @Column(name = "`beyj`") + @ApiModelProperty(value = "是否发邮件") + private Boolean beyj=false; + + @Column(name = "`yj_des`") + @ApiModelProperty(value = "邮件备注") + private String yjDes; + + @Column(name = "`yj_sjr`") + @ApiModelProperty(value = "邮件收件人") + private String yjSjr; + + @Column(name = "`betc`") + @ApiModelProperty(value = "是否弹窗") + private Boolean betc=false; + + @Column(name = "`tc_msg`") + @ApiModelProperty(value = "弹窗消息") + private String tcMsg; + + @Column(name = "`beys`") + @ApiModelProperty(value = "颜色标记") + private Boolean beys=false; + + @Column(name = "`ys_flg`") + @ApiModelProperty(value = "标记颜色值") + private String ysFlg; + + @Column(name = "`ys_field`") + @ApiModelProperty(value = "标记颜色字段") + private String ysField; + + @Column(name = "`gs_content`") + @ApiModelProperty(value = "格式校验正则表达式") + private String gsContent; + + @Column(name = "`bekz1`") + @ApiModelProperty(value = "扩展1标记") + private Boolean bekz1=false; + + @Column(name = "`kz1_msg`") + @ApiModelProperty(value = "扩展1消息") + private String kz1Msg; + + @Column(name = "`kz1_content`") + @ApiModelProperty(value = "扩展1内容") + private String kz1Content; + + @Column(name = "`bekz2`") + @ApiModelProperty(value = "扩展2标记") + private Boolean bekz2=false; + + @Column(name = "`kz2_msg`") + @ApiModelProperty(value = "扩展2消息") + private String kz2Msg; + + @Column(name = "`kz2_content`") + @ApiModelProperty(value = "扩展2内容") + private String kz2Content; + + @Column(name = "`bekz3`") + @ApiModelProperty(value = "扩展3标记") + private Boolean bekz3=false; + + @Column(name = "`kz3_msg`") + @ApiModelProperty(value = "扩展3消息") + private String kz3Msg; + + @Column(name = "`kz3_content`") + @ApiModelProperty(value = "扩展3内容") + private String kz3Content; + + @Column(name = "`bekz4`") + @ApiModelProperty(value = "扩展4标记") + private Boolean bekz4=false; + + @Column(name = "`kz4_msg`") + @ApiModelProperty(value = "扩展4消息") + private String kz4Msg; + + @Column(name = "`kz4_content`") + @ApiModelProperty(value = "扩展4内容") + private String kz4Content; + + @Column(name = "`bekz5`") + @ApiModelProperty(value = "扩展5标记") + private Boolean bekz5=false; + + @Column(name = "`kz5_msg`") + @ApiModelProperty(value = "扩展5消息") + private String kz5Msg; + + @Column(name = "`kz5_content`") + @ApiModelProperty(value = "扩展5内容") + private String kz5Content; + + + public void copy(RuleConfigure source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/youchain-system/src/main/java/com/youchain/basicdata/repository/RuleConfigureRepository.java b/youchain-system/src/main/java/com/youchain/basicdata/repository/RuleConfigureRepository.java new file mode 100644 index 0000000..5a0dd7d --- /dev/null +++ b/youchain-system/src/main/java/com/youchain/basicdata/repository/RuleConfigureRepository.java @@ -0,0 +1,28 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package com.youchain.basicdata.repository; + +import com.youchain.basicdata.domain.RuleConfigure; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +/** +* @website https://eladmin.vip +* @author houjianlan +* @date 2024-09-14 +**/ +public interface RuleConfigureRepository extends JpaRepository, JpaSpecificationExecutor { +} \ No newline at end of file diff --git a/youchain-system/src/main/java/com/youchain/basicdata/rest/RuleConfigureController.java b/youchain-system/src/main/java/com/youchain/basicdata/rest/RuleConfigureController.java new file mode 100644 index 0000000..36f9208 --- /dev/null +++ b/youchain-system/src/main/java/com/youchain/basicdata/rest/RuleConfigureController.java @@ -0,0 +1,99 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package com.youchain.basicdata.rest; + +import com.youchain.annotation.Log; +import com.youchain.basicdata.domain.RuleConfigure; +import com.youchain.basicdata.service.RuleConfigureService; +import com.youchain.basicdata.service.dto.RuleConfigureQueryCriteria; +import com.youchain.exception.BadRequestException; +import com.youchain.modules.quartz.task.TestTask; +import com.youchain.utils.RegexUtils; +import org.springframework.data.domain.Pageable; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import io.swagger.annotations.*; +import java.io.IOException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.servlet.http.HttpServletResponse; + +/** +* @website https://eladmin.vip +* @author houjianlan +* @date 2024-09-14 +**/ +@RestController +@RequiredArgsConstructor +@Api(tags = "RuleConfigure管理") +@RequestMapping("/api/ruleConfigure") +public class RuleConfigureController { + + private final RuleConfigureService ruleConfigureService; + private final TestTask testTask; + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") + @PreAuthorize("@el.check('ruleConfigure:list')") + public void exportRuleConfigure(HttpServletResponse response, RuleConfigureQueryCriteria criteria) throws Exception { + ruleConfigureService.download(ruleConfigureService.queryAll(criteria), response); + } + + @GetMapping + @Log("查询RuleConfigure") + @ApiOperation("查询RuleConfigure") + @PreAuthorize("@el.check('ruleConfigure:list')") + public ResponseEntity queryRuleConfigure(RuleConfigureQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(ruleConfigureService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @PostMapping + @Log("新增RuleConfigure") + @ApiOperation("新增RuleConfigure") + @PreAuthorize("@el.check('ruleConfigure:add')") + public ResponseEntity createRuleConfigure(@Validated @RequestBody RuleConfigure resources){ + if(resources.getBeyj()){ + RegexUtils.emailRegex(resources.getYjSjr()); + } + return new ResponseEntity<>(ruleConfigureService.create(resources),HttpStatus.CREATED); + } + + @PutMapping + @Log("修改RuleConfigure") + @ApiOperation("修改RuleConfigure") + @PreAuthorize("@el.check('ruleConfigure:edit')") + public ResponseEntity updateRuleConfigure(@Validated @RequestBody RuleConfigure resources){ + if(resources.getBeyj()){ + RegexUtils.emailRegex(resources.getYjSjr()); + } + ruleConfigureService.update(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @DeleteMapping + @Log("删除RuleConfigure") + @ApiOperation("删除RuleConfigure") + @PreAuthorize("@el.check('ruleConfigure:del')") + public ResponseEntity deleteRuleConfigure(@RequestBody Long[] ids) { + ruleConfigureService.deleteAll(ids); + return new ResponseEntity<>(HttpStatus.OK); + } +} \ No newline at end of file diff --git a/youchain-system/src/main/java/com/youchain/basicdata/rest/StockController.java b/youchain-system/src/main/java/com/youchain/basicdata/rest/StockController.java index 1817e92..c09fc39 100644 --- a/youchain-system/src/main/java/com/youchain/basicdata/rest/StockController.java +++ b/youchain-system/src/main/java/com/youchain/basicdata/rest/StockController.java @@ -204,8 +204,8 @@ public class StockController { @PostMapping(value = "/stockMsg") @AnonymousAccess - public ResponseEntity stockMsg(String msg) { - String stockMsg = stockService.stockMsg(msg); + public ResponseEntity stockMsg() { + String stockMsg = stockService.stockMsg(); return new ResponseEntity<>(stockMsg, HttpStatus.OK); } diff --git a/youchain-system/src/main/java/com/youchain/basicdata/service/RuleConfigureService.java b/youchain-system/src/main/java/com/youchain/basicdata/service/RuleConfigureService.java new file mode 100644 index 0000000..605b9b4 --- /dev/null +++ b/youchain-system/src/main/java/com/youchain/basicdata/service/RuleConfigureService.java @@ -0,0 +1,83 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package com.youchain.basicdata.service; + +import com.youchain.basicdata.domain.RuleConfigure; +import com.youchain.basicdata.service.dto.RuleConfigureDto; +import com.youchain.basicdata.service.dto.RuleConfigureQueryCriteria; +import org.springframework.data.domain.Pageable; +import java.util.Map; +import java.util.List; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; + +/** +* @website https://eladmin.vip +* @description 服务接口 +* @author houjianlan +* @date 2024-09-14 +**/ +public interface RuleConfigureService { + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(RuleConfigureQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(RuleConfigureQueryCriteria criteria); + + /** + * 根据ID查询 + * @param id ID + * @return RuleConfigureDto + */ + RuleConfigureDto findById(Long id); + + /** + * 创建 + * @param resources / + * @return RuleConfigureDto + */ + RuleConfigureDto create(RuleConfigure resources); + + /** + * 编辑 + * @param resources / + */ + void update(RuleConfigure resources); + + /** + * 多选删除 + * @param ids / + */ + void deleteAll(Long[] ids); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws Exception / + */ + void download(List all, HttpServletResponse response) throws Exception; +} \ No newline at end of file diff --git a/youchain-system/src/main/java/com/youchain/basicdata/service/dto/RuleConfigureDto.java b/youchain-system/src/main/java/com/youchain/basicdata/service/dto/RuleConfigureDto.java new file mode 100644 index 0000000..aa2036e --- /dev/null +++ b/youchain-system/src/main/java/com/youchain/basicdata/service/dto/RuleConfigureDto.java @@ -0,0 +1,125 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package com.youchain.basicdata.service.dto; + +import lombok.Data; +import java.sql.Timestamp; +import java.io.Serializable; + +/** +* @website https://eladmin.vip +* @description / +* @author houjianlan +* @date 2024-09-14 +**/ +@Data +public class RuleConfigureDto implements Serializable { + + private Long id; + + /** 规则类型 */ + private String ruleType; + + /** SQL内容 */ + private String sqlContent; + + /** 描述 */ + private String description; + + /** 是否发邮件 */ + private Boolean beyj; + + /** 邮件备注 */ + private String yjDes; + + /** 邮件收件人 */ + private String yjSjr; + + /** 是否弹窗 */ + private Boolean betc; + + /** 弹窗消息 */ + private String tcMsg; + + /** 颜色标记 */ + private Boolean beys; + + /** 标记颜色值 */ + private String ysFlg; + + /** 标记颜色字段 */ + private String ysField; + + /** 格式校验正则表达式 */ + private String gsContent; + + /** 扩展1标记 */ + private Boolean bekz1; + + /** 扩展1消息 */ + private String kz1Msg; + + /** 扩展1内容 */ + private String kz1Content; + + /** 扩展2标记 */ + private Boolean bekz2; + + /** 扩展2消息 */ + private String kz2Msg; + + /** 扩展2内容 */ + private String kz2Content; + + /** 扩展3标记 */ + private Boolean bekz3; + + /** 扩展3消息 */ + private String kz3Msg; + + /** 扩展3内容 */ + private String kz3Content; + + /** 扩展4标记 */ + private Boolean bekz4; + + /** 扩展4消息 */ + private String kz4Msg; + + /** 扩展4内容 */ + private String kz4Content; + + /** 扩展5标记 */ + private Boolean bekz5; + + /** 扩展5消息 */ + private String kz5Msg; + + /** 扩展5内容 */ + private String kz5Content; + + /** 创建人 */ + private String createBy; + + /** 更新人 */ + private String updateBy; + + /** 创建时间 */ + private Timestamp createTime; + + /** 更新时间 */ + private Timestamp updateTime; +} \ No newline at end of file diff --git a/youchain-system/src/main/java/com/youchain/basicdata/service/dto/RuleConfigureQueryCriteria.java b/youchain-system/src/main/java/com/youchain/basicdata/service/dto/RuleConfigureQueryCriteria.java new file mode 100644 index 0000000..d908f96 --- /dev/null +++ b/youchain-system/src/main/java/com/youchain/basicdata/service/dto/RuleConfigureQueryCriteria.java @@ -0,0 +1,37 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package com.youchain.basicdata.service.dto; + +import lombok.Data; +import java.util.List; +import com.youchain.annotation.Query; + +/** +* @website https://eladmin.vip +* @author houjianlan +* @date 2024-09-14 +**/ +@Data +public class RuleConfigureQueryCriteria{ + + /** 精确 */ + @Query + private String ruleType; + + /** 模糊 */ + @Query(type = Query.Type.INNER_LIKE) + private String sqlContent; +} \ No newline at end of file diff --git a/youchain-system/src/main/java/com/youchain/basicdata/service/impl/RuleConfigureServiceImpl.java b/youchain-system/src/main/java/com/youchain/basicdata/service/impl/RuleConfigureServiceImpl.java new file mode 100644 index 0000000..b6032ca --- /dev/null +++ b/youchain-system/src/main/java/com/youchain/basicdata/service/impl/RuleConfigureServiceImpl.java @@ -0,0 +1,134 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package com.youchain.basicdata.service.impl; + +import com.youchain.basicdata.domain.RuleConfigure; +import com.youchain.utils.FileUtil; +import com.youchain.utils.PageUtil; +import com.youchain.utils.QueryHelp; +import com.youchain.utils.ValidationUtil; +import lombok.RequiredArgsConstructor; +import com.youchain.basicdata.repository.RuleConfigureRepository; +import com.youchain.basicdata.service.RuleConfigureService; +import com.youchain.basicdata.service.dto.RuleConfigureDto; +import com.youchain.basicdata.service.dto.RuleConfigureQueryCriteria; +import com.youchain.basicdata.service.mapstruct.RuleConfigureMapper; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import java.util.List; +import java.util.Map; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.LinkedHashMap; + +/** +* @website https://eladmin.vip +* @description 服务实现 +* @author houjianlan +* @date 2024-09-14 +**/ +@Service +@RequiredArgsConstructor +public class RuleConfigureServiceImpl implements RuleConfigureService { + + private final RuleConfigureRepository ruleConfigureRepository; + private final RuleConfigureMapper ruleConfigureMapper; + + @Override + public Map queryAll(RuleConfigureQueryCriteria criteria, Pageable pageable){ + Page page = ruleConfigureRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); + return PageUtil.toPage(page.map(ruleConfigureMapper::toDto)); + } + + @Override + public List queryAll(RuleConfigureQueryCriteria criteria){ + return ruleConfigureMapper.toDto(ruleConfigureRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); + } + + @Override + @Transactional + public RuleConfigureDto findById(Long id) { + RuleConfigure ruleConfigure = ruleConfigureRepository.findById(id).orElseGet(RuleConfigure::new); + ValidationUtil.isNull(ruleConfigure.getId(),"RuleConfigure","id",id); + return ruleConfigureMapper.toDto(ruleConfigure); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public RuleConfigureDto create(RuleConfigure resources) { + return ruleConfigureMapper.toDto(ruleConfigureRepository.save(resources)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(RuleConfigure resources) { + RuleConfigure ruleConfigure = ruleConfigureRepository.findById(resources.getId()).orElseGet(RuleConfigure::new); + ValidationUtil.isNull( ruleConfigure.getId(),"RuleConfigure","id",resources.getId()); + ruleConfigure.copy(resources); + ruleConfigureRepository.save(ruleConfigure); + } + + @Override + public void deleteAll(Long[] ids) { + for (Long id : ids) { + ruleConfigureRepository.deleteById(id); + } + } + + @Override + public void download(List all, HttpServletResponse response) throws Exception { + List> list = new ArrayList<>(); + for (RuleConfigureDto ruleConfigure : all) { + Map map = new LinkedHashMap<>(); + map.put("规则类型", ruleConfigure.getRuleType()); + map.put("SQL内容", ruleConfigure.getSqlContent()); + map.put("描述", ruleConfigure.getDescription()); + map.put("是否发邮件", ruleConfigure.getBeyj()); + map.put("邮件备注", ruleConfigure.getYjDes()); + map.put("邮件收件人", ruleConfigure.getYjSjr()); + map.put("是否弹窗", ruleConfigure.getBetc()); + map.put("弹窗消息", ruleConfigure.getTcMsg()); + map.put("颜色标记", ruleConfigure.getBeys()); + map.put("标记颜色值", ruleConfigure.getYsFlg()); + map.put("标记颜色字段", ruleConfigure.getYsField()); + map.put("格式校验正则表达式", ruleConfigure.getGsContent()); + map.put("扩展1标记", ruleConfigure.getBekz1()); + map.put("扩展1消息", ruleConfigure.getKz1Msg()); + map.put("扩展1内容", ruleConfigure.getKz1Content()); + map.put("扩展2标记", ruleConfigure.getBekz2()); + map.put("扩展2消息", ruleConfigure.getKz2Msg()); + map.put("扩展2内容", ruleConfigure.getKz2Content()); + map.put("扩展3标记", ruleConfigure.getBekz3()); + map.put("扩展3消息", ruleConfigure.getKz3Msg()); + map.put("扩展3内容", ruleConfigure.getKz3Content()); + map.put("扩展4标记", ruleConfigure.getBekz4()); + map.put("扩展4消息", ruleConfigure.getKz4Msg()); + map.put("扩展4内容", ruleConfigure.getKz4Content()); + map.put("扩展5标记", ruleConfigure.getBekz5()); + map.put("扩展5消息", ruleConfigure.getKz5Msg()); + map.put("扩展5内容", ruleConfigure.getKz5Content()); + map.put("创建人", ruleConfigure.getCreateBy()); + map.put("更新人", ruleConfigure.getUpdateBy()); + map.put("创建时间", ruleConfigure.getCreateTime()); + map.put("更新时间", ruleConfigure.getUpdateTime()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} \ No newline at end of file diff --git a/youchain-system/src/main/java/com/youchain/basicdata/service/mapstruct/RuleConfigureMapper.java b/youchain-system/src/main/java/com/youchain/basicdata/service/mapstruct/RuleConfigureMapper.java new file mode 100644 index 0000000..57908a1 --- /dev/null +++ b/youchain-system/src/main/java/com/youchain/basicdata/service/mapstruct/RuleConfigureMapper.java @@ -0,0 +1,32 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package com.youchain.basicdata.service.mapstruct; + +import com.youchain.base.BaseMapper; +import com.youchain.basicdata.domain.RuleConfigure; +import com.youchain.basicdata.service.dto.RuleConfigureDto; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; + +/** +* @website https://eladmin.vip +* @author houjianlan +* @date 2024-09-14 +**/ +@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface RuleConfigureMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/youchain-system/src/main/java/com/youchain/modules/quartz/task/TestTask.java b/youchain-system/src/main/java/com/youchain/modules/quartz/task/TestTask.java new file mode 100644 index 0000000..de229c7 --- /dev/null +++ b/youchain-system/src/main/java/com/youchain/modules/quartz/task/TestTask.java @@ -0,0 +1,102 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.youchain.modules.quartz.task; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.youchain.annotation.AnonymousAccess; +import com.youchain.basicdata.domain.Point; +import com.youchain.basicdata.domain.RuleConfigure; +import com.youchain.basicdata.domain.Stock; +import com.youchain.basicdata.repository.RuleConfigureRepository; +import com.youchain.basicdata.service.StockService; +import com.youchain.businessdata.domain.PickDetail; +import com.youchain.businessdata.domain.Task; +import com.youchain.businessdata.service.TaskService; +import com.youchain.utils.BaseStatus; +import com.youchain.utils.BizStatus; +import com.youchain.utils.Email.EmailUtils; +import lombok.extern.slf4j.Slf4j; +import org.hibernate.SQLQuery; +import org.hibernate.transform.AliasToEntityMapResultTransformer; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.persistence.EntityManager; +import javax.persistence.Query; +import java.util.ArrayList; +import java.util.List; + + + +/** + * 测试用 + * @author Liu Xue + * @date 2019-01-08 + */ +@Slf4j + +@Component("testTask") +@Service +public class TestTask { + @Autowired + private EntityManager entityManager; + @Autowired + private RuleConfigureRepository ruleConfigureRepository; + @Autowired + private StockService stockService; + private static int MAX_TASK_COUNT = 4; + public static int MAX_HS_COUNT = 4; + //限制时间 + private static long TIMEOUT_MS = 600000; // 10分钟,以毫秒为单位 + private long lastTaskTime = System.currentTimeMillis(); + + +// @Bean(autowire = Autowire.BY_NAME,value = "testTask") + @AnonymousAccess + public synchronized void reminderRules() { + System.out.println("执行一次定时任务"); + List ruleConfigures= ruleConfigureRepository.findAll(); + System.out.println("执行一次定时任务2"); + for(RuleConfigure ruleConfigure:ruleConfigures) { + String sql=ruleConfigure.getSqlContent(); + List taskList= entityManager.createNativeQuery(sql) + .unwrap(SQLQuery.class) + .setResultTransformer( + AliasToEntityMapResultTransformer.INSTANCE + ) + .list(); + if(taskList.size()>0){ + stockService.stockMsg(ruleConfigure.getTcMsg()); + EmailUtils.sendNodecrypPwd("预警提醒",ruleConfigure.getYjDes(),ruleConfigure.getYjSjr().split(";")); + } + } + } + + + + + public static void main(String[] args) throws JsonProcessingException { + + } +} diff --git a/youchain-system/src/main/java/com/youchain/utils/RegexUtils.java b/youchain-system/src/main/java/com/youchain/utils/RegexUtils.java new file mode 100644 index 0000000..928f64f --- /dev/null +++ b/youchain-system/src/main/java/com/youchain/utils/RegexUtils.java @@ -0,0 +1,32 @@ +package com.youchain.utils; + +import cn.hutool.core.util.RandomUtil; +import com.youchain.exception.BadRequestException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +@Component +@Slf4j +public class RegexUtils { + public static void emailRegex(String input){ + if(input==null){ + throw new BadRequestException("邮件收件人必填"); + } + String[] emails=input.split(";"); + for(int i=0;i