Commit 2efd82d5 by HlQ

[add] 项目代码提交

1 parent ee3b94fe
Showing 119 changed files with 2067 additions and 1219 deletions
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
src/main/test/
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="NodePackageJsonFileManager">
<packageJsonPaths />
</component>
</project>
\ No newline at end of file
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile default="true" name="Default" enabled="true" />
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="Vion-DevOps" />
</profile>
</annotationProcessing>
</component>
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="Vion-DevOps" options="-parameters" />
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="vion-nexus" />
<option name="name" value="vion-nexus" />
<option name="url" value="http://maven.vionyun.com:8081/nexus/content/groups/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="aliyun-nexus" />
<option name="name" value="aliyun-nexus" />
<option name="url" value="http://maven.aliyun.com/nexus/content/groups/public" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -8,34 +8,23 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.14</version>
<version>2.7.17</version>
</parent>
<artifactId>Vion-DevOps</artifactId>
<version>1</version>
<dependencies>
<dependency>
<groupId>net.minidev</groupId>
<artifactId>json-smart</artifactId>
<version>2.2.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.3.8</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
<version>42.6.0</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.20</version>
<version>1.18.30</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
......@@ -43,91 +32,64 @@
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.15</version>
</dependency>
<dependency>
<groupId>com.mks.api</groupId>
<artifactId>mksapi-jar</artifactId>
<version>4.10.9049</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>dingtalk</artifactId>
<version>2.0.14</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.47</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.14</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>alibaba-dingtalk-service-sdk</artifactId>
<version>2.0.0</version>
<version>5.8.22</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.4.0</version>
<groupId>io.github.linpeilie</groupId>
<artifactId>mapstruct-plus-spring-boot-starter</artifactId>
<version>1.3.5</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.1</version>
<version>3.5.4</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java-mp-spring-boot-starter</artifactId>
<version>4.5.0</version>
</dependency>
</dependencies>
<build>
<finalName>VVAS-Task</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>vion.Application</mainClass>
<layout>JAR</layout>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<excludes>
<exclude>application-*.properties</exclude>
</excludes>
<source>1.8</source>
<target>1.8</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
</path>
<path>
<groupId>io.github.linpeilie</groupId>
<artifactId>mapstruct-plus-processor</artifactId>
<version>1.3.5</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>0.2.0</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package vion;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import vion.controller.UserController;
import java.util.concurrent.CountDownLatch;
import vion.ding.DingMod;
@SpringBootApplication
@MapperScan("vion.mapper")
@EnableScheduling
public class Application implements CommandLineRunner {
public class Application {
public static void main(String[] args) {
try {
SpringApplication.run(Application.class, args);
new CountDownLatch(1).await();
} catch (Exception e) {
e.printStackTrace();
}
SpringApplication.run(Application.class, args);
}
@Autowired
private UserController userController;
private DingMod dingMod;
private final static Logger logger = LoggerFactory.getLogger(Application.class);
//@Scheduled(fixedDelay=1000*60*10,initialDelay=1000)
@Scheduled(cron="${third.run.cron:0 0 2 * * ?}")
public void startJob(){
@Scheduled(cron = "${third.run.cron:0 0 2 * * ?}")
public void startJob() {
try {
logger.info("启动");
//定时获取钉钉用户列表
userController.getDingUserList();
//USERNAME_MAP
dingMod.getDeptList();
dingMod.getDingUserList();
logger.info("启动完成");
} catch (Exception e) {
e.printStackTrace();
// System.exit(-1);
}
}
@Override
public void run(String... args) throws Exception {
}
}
......@@ -2,7 +2,6 @@ package vion;
import vion.model.User;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
......@@ -13,5 +12,4 @@ public class Global {
public static final String WORK_URL = "/api/work";
public static final String INSPECT_URL = "/api/inspect";
public static final Map<String, User> USERNAME_MAP = new ConcurrentHashMap<>();
public static final Map<String, String> IP_MALL_MAP = new HashMap<>();
}
package vion.advice;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.MethodParameter;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
import vion.utils.ResultUtil;
import vion.vo.ResultVO;
/**
* @author HlQ
* @date 2023/11/2
*/
@Component
@RestControllerAdvice("vion.controller")
@Slf4j
public class ResBodyAdvice implements ResponseBodyAdvice<Object> {
@Override
public boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType) {
return !returnType.getMethod().getReturnType().isAssignableFrom(Void.TYPE);
}
@Override
public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType, Class selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
if (body instanceof ResultVO || body instanceof ModelAndView) {
return body;
}
ResultVO resultVO = ResultUtil.success(body);
if (returnType.getParameterType().isAssignableFrom(String.class)) {
// 字符串类型特殊处理
try {
return new ObjectMapper().writeValueAsString(resultVO);
} catch (JsonProcessingException e) {
}
}
return resultVO;
}
@ExceptionHandler(Exception.class)
public Object exceptionHandler(Exception e) {
log.error("接口调用出错", e);
return ResultUtil.error(e.getMessage());
}
@ExceptionHandler(IllegalArgumentException.class)
public Object argExceptionHandler(Exception e) {
log.error("参数异常", e);
return ResultUtil.error(e.getMessage());
}
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
public Object methodArgExceptionHandler(Exception e) {
log.error("方法参数异常", e);
return ResultUtil.error("Method parameter error.");
}
}
package vion.config;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.Date;
/**
* @author HlQ
* @date 2022/7/20
*/
@Configuration
public class MyBatisPlusConfig implements MetaObjectHandler {
@Override
public void insertFill(MetaObject metaObject) {
this.fillHasGetter(metaObject, "createTime", new Date());
this.fillHasGetter(metaObject, "modifyTime", new Date());
this.fillHasGetter(metaObject, "updateTime", new Date());
}
@Override
public void updateFill(MetaObject metaObject) {
this.fillHasGetter(metaObject, "modifyTime", new Date());
this.fillHasGetter(metaObject, "updateTime", new Date());
}
protected void fillHasGetter(MetaObject metaObject, String fieldName, Object fieldVal) {
if (metaObject.hasGetter(fieldName)) {
this.fillStrategy(metaObject, fieldName, fieldVal);
}
}
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.POSTGRE_SQL));
return interceptor;
}
}
package vion.controller;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import vion.Global;
import vion.enums.ResultEnum;
import vion.model.Account;
import vion.model.Store;
import vion.service.IAccountSerrvice;
import vion.utils.ResultUtil;
import vion.service.IAccountService;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
@Controller
@RestController
@RequestMapping(Global.BASE_URL)
@RequiredArgsConstructor
@Slf4j
public class AccountController {
@Autowired
private IAccountSerrvice accountSerrvice;
private final IAccountService accountService;
@GetMapping("/accounts")
@ResponseBody
public Object getAccountList(@RequestParam(name = "pageNum")Integer pageNum,
@RequestParam(name = "pageSize")Integer pageSize){
//pageNum当前页,pageSize每页条数
Page page= PageHelper.startPage(pageNum,pageSize);
List<Account> accountList=accountSerrvice.list();
accountList.sort(Comparator.comparing(Account::getId));
PageInfo pageInfo=new PageInfo<>(page);
pageInfo.setList(accountList);
if (accountList != null) {
return ResultUtil.success(pageInfo);
} else {
return ResultUtil.error(ResultEnum.SELECT_ERROR);
}
public Page<Account> getAccountList(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "10") Integer pageSize) {
return accountService.page(Page.of(pageNum, pageSize));
}
@GetMapping("/account")
@ResponseBody
public Object getProductByID(@RequestParam(name = "id")Integer id){
Account account=accountSerrvice.getById(id);//accountDao.getAccountById(id);
if (account != null) {
return ResultUtil.success(account);
} else {
return ResultUtil.error(ResultEnum.SELECT_ERROR);
}
public Account getProductByID(Integer id) {
return accountService.getById(id);
}
@PostMapping("/accounts")
@ResponseBody
public Object saveOrUpdate(@RequestBody Account data) {
try {
if(data.getId()==null){
data.setCreateTime(new Date());
}else{
data.setModifyTime(new Date());
}
Account account= accountSerrvice.saveAndReturn(data);
return ResultUtil.success(account);
}catch (Exception e) {
return ResultUtil.error(ResultEnum.SELECT_ERROR);
}
public Account saveOrUpdate(@RequestBody Account data) {
accountService.save(data);
return data;
}
}
package vion.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import vion.Global;
import vion.enums.ResultEnum;
import vion.dto.DictionaryDTO;
import vion.dto.DictionaryTypeDTO;
import vion.model.Dictionary;
import vion.model.DictionaryType;
import vion.model.Store;
import vion.service.IDictionarySerrvice;
import vion.service.IDictionaryTypeSerrvice;
import vion.utils.ResultUtil;
import java.util.Comparator;
import java.util.List;
import vion.service.IDictionaryService;
import vion.service.IDictionaryTypeService;
@RestController
@RequestMapping(Global.BASE_URL)
@RequiredArgsConstructor
@Slf4j
public class DictionaryController {
@Autowired
private IDictionarySerrvice dictionarySerrvice;
@Autowired
private IDictionaryTypeSerrvice dictionaryTypeSerrvice;
private final IDictionaryService dictionaryService;
private final IDictionaryTypeService dictionaryTypeService;
private final Converter converter;
@GetMapping("/dictionarys")
@ResponseBody
public Object getDictionaryList(@RequestParam(name = "pageNum")Integer pageNum,
@RequestParam(name = "pageSize")Integer pageSize,
@RequestParam(name = "type",required=false)String type){
//pageNum当前页,pageSize每页条数
Page page= PageHelper.startPage(pageNum,pageSize);
QueryWrapper<Dictionary> wrapper=new QueryWrapper<>();
if(type!=null)
wrapper.eq("type",type);
List<Dictionary> dictionaryList=dictionarySerrvice.list(wrapper);
dictionaryList.sort(Comparator.comparing(Dictionary::getId));
PageInfo pageInfo=new PageInfo<>(page);
pageInfo.setList(dictionaryList);
if (dictionaryList != null) {
return ResultUtil.success(pageInfo);
} else {
return ResultUtil.error(ResultEnum.SELECT_ERROR);
}
public Page<Dictionary> getDictionaryList(DictionaryDTO data) {
return dictionaryService.lambdaQuery(converter.convert(data, new Dictionary()))
.page(Page.of(data.getPageNum(), data.getPageSize()));
}
@GetMapping("/dictionary")
@ResponseBody
public Object getDictionaryByID(@RequestParam(name = "id")Integer id){
Dictionary dictionary=dictionarySerrvice.getById(id);
public Object getDictionaryByID(@RequestParam(name = "id") Integer id) {
return dictionaryService.getById(id);
if (dictionary != null) {
return ResultUtil.success(dictionary);
} else {
return ResultUtil.error(ResultEnum.SELECT_ERROR);
}
}
@PostMapping("/dictionarys")
@ResponseBody
public Object saveOrUpdateDictionary(@RequestBody Dictionary data) {
try {
dictionarySerrvice.saveOrUpdate(data);
return ResultUtil.success();
}catch (Exception e) {
return ResultUtil.error(ResultEnum.SELECT_ERROR);
}
@PostMapping("/dictionary")
public String saveOrUpdateDictionary(@RequestBody DictionaryDTO data) {
Dictionary dictionary = converter.convert(data, new Dictionary());
return dictionaryService.saveOrUpdate(dictionary) ? "成功" : "失败";
}
@GetMapping("/dictionaryTypes")
@ResponseBody
public Object getDictionaryTypeList(@RequestParam(name = "pageNum")Integer pageNum,
@RequestParam(name = "pageSize")Integer pageSize){
//pageNum当前页,pageSize每页条数
PageHelper.startPage(pageNum,pageSize);
List<DictionaryType> dictionaryTypeList=dictionaryTypeSerrvice.list();
PageInfo pageInfo=new PageInfo(dictionaryTypeList,10);
if (dictionaryTypeList != null) {
return ResultUtil.success(pageInfo);
} else {
return ResultUtil.error(ResultEnum.SELECT_ERROR);
}
public Page<DictionaryType> getDictionaryTypeList(DictionaryTypeDTO data) {
return dictionaryTypeService.lambdaQuery(converter.convert(data, new DictionaryType()))
.page(Page.of(data.getPageNum(), data.getPageSize()));
}
@GetMapping("/dictionaryType")
@ResponseBody
public Object getDictionaryTypeByID(@RequestParam(name = "id")Integer id){
DictionaryType dictionaryType=dictionaryTypeSerrvice.getById(id);
if (dictionaryType != null) {
return ResultUtil.success(dictionaryType);
} else {
return ResultUtil.error(ResultEnum.SELECT_ERROR);
}
public Object getDictionaryTypeByID(@RequestParam Integer id) {
return dictionaryTypeService.getById(id);
}
@PostMapping("/dictionaryTypes")
@ResponseBody
public Object saveOrUpdateDictionaryType(@RequestBody DictionaryType data) {
try {
dictionaryTypeSerrvice.saveOrUpdate(data);
return ResultUtil.success();
}catch (Exception e) {
return ResultUtil.error(ResultEnum.SELECT_ERROR);
}
@PostMapping("/dictionaryType")
public String saveOrUpdateDictionaryType(@RequestBody DictionaryTypeDTO data) {
DictionaryType dictionaryType = converter.convert(data, new DictionaryType());
return dictionaryTypeService.saveOrUpdate(dictionaryType) ? "成功" : "失败";
}
}
package vion.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.crypto.SecureUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import vion.Global;
import vion.enums.ResultEnum;
import vion.model.File;
import vion.model.Inspect;
import vion.model.Store;
import vion.service.IFileSerrvice;
import vion.dto.FileInfoDTO;
import vion.model.FileInfo;
import vion.service.IFileService;
import vion.utils.ResultUtil;
import vion.vo.StoreVO;
import vion.vo.ResultVO;
import javax.servlet.http.HttpServletResponse;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Date;
@RestController
@RequestMapping(Global.BASE_URL)
@RequiredArgsConstructor
@Slf4j
public class FileController {
@Autowired
private IFileSerrvice fileSerrvice;
private final IFileService fileService;
private final Converter converter;
@Value("${fileurl:}")
@Value("${fileUrl:}")
private String fileurl;
@GetMapping("/files")
@ResponseBody
public Object getFiles(@RequestParam(name = "storeId",required=false)Integer store_id,
@RequestParam(name = "sourceId",required=false)Integer source_id,
@RequestParam(name = "pageNum")Integer pageNum,
@RequestParam(name = "pageSize")Integer pageSize){
//pageNum当前页,pageSize每页条数
Page page= PageHelper.startPage(pageNum,pageSize);
QueryWrapper<File> wrapper=new QueryWrapper<>();
if(store_id!=null)
wrapper.eq("store_id",store_id);
if(source_id!=null)
wrapper.eq("source_id",source_id);
List<File> fileList=fileSerrvice.list(wrapper);
fileList.sort(Comparator.comparing(File::getId));
PageInfo pageInfo=new PageInfo<>(page);
pageInfo.setList(fileList);
if (pageInfo != null) {
return ResultUtil.success(pageInfo);
} else {
return ResultUtil.error(ResultEnum.SELECT_ERROR);
}
public Page<FileInfo> getFiles(FileInfoDTO data) {
return fileService.lambdaQuery(converter.convert(data, new FileInfo()))
.page(Page.of(data.getPageNum(), data.getPageSize()));
}
@PostMapping("/files")
@ResponseBody
public Map<String, Object> getFile(@RequestBody File file){
Map<String, Object> resultMap = new HashMap<String, Object>();
try {
//添加文件附件
File tempFile=new File();
tempFile.setStoreId(file.getStoreId());
tempFile.setSourceId(file.getSourceId());
tempFile.setSourceType(file.getSourceType());//1项目、2工单预处理,3工单操作,4巡检
tempFile.setName(file.getName());
tempFile.setUrl(file.getUrl());
tempFile.setType(file.getType());
fileSerrvice.save(tempFile);
resultMap.put("msg_code", 200);
} catch (Exception e) {
e.printStackTrace();
resultMap.put("msg_code", 500);
}
return resultMap;
}
@GetMapping("/deleteFile")
@ResponseBody
public Map<String, Object> deleteFile(@RequestParam(name = "id")Integer id){
Map<String, Object> resultMap = new HashMap<String, Object>();
try {
//解除文件关系
fileSerrvice.lambdaUpdate()
.setSql("id="+id)
.eq(File::getSourceId,-1)
.update();
resultMap.put("msg_code", 200);
} catch (Exception e) {
e.printStackTrace();
resultMap.put("msg_code", 500);
@DeleteMapping("/file/{id}")
public String remove(@PathVariable(name = "id") Integer id) {
FileInfo file = fileService.getById(id);
if (FileUtil.del(file.getUrl())) {
fileService.removeById(id);
return "文件删除成功";
} else {
return "文件删除失败";
}
return resultMap;
}
/*
* todo
* 手机端工单预处理提交
* 项目阶段修改,待联调 sourceType=1 这里的附件查询
* 工单处理上传附件
*/
@PostMapping("/upLoadFile")
public Map<String, Object> uploadFile(@RequestParam(name="file") MultipartFile file){
Map<String, Object> resultMap = new HashMap<String, Object>();
public ResultVO uploadFile(Long storeId, Long sourceId, FileInfo fileInfo, @RequestParam(name = "file") MultipartFile infile) {
try {
//上传url地址
String path=fileurl+"/"+file.getOriginalFilename();
java.io.File fileinfo=new java.io.File(path);
file.transferTo(fileinfo);
resultMap.put("msg_code", 200);
resultMap.put("fileUrl",path);
String filename = infile.getOriginalFilename() + "_" + DateUtil.format(new Date(), DatePattern.PURE_DATETIME_PATTERN);
// String path = fileurl + FileUtil.FILE_SEPARATOR + storeId + FileUtil.FILE_SEPARATOR + sourceId + FileUtil.FILE_SEPARATOR + filename;
String path = fileurl + FileUtil.FILE_SEPARATOR + filename;
File file = FileUtil.touch(path);
infile.transferTo(file);
String sha256 = SecureUtil.sha256(file).toUpperCase();
String extName = FileUtil.extName(file);
return ResultUtil.success(path);
} catch (IOException e) {
e.printStackTrace();
resultMap.put("msg_code", 500);
resultMap.put("message",e.getMessage());
}
return resultMap;
}
return ResultUtil.success();
@GetMapping("/downLoadFile")
public void downLoadFile(@RequestParam(name="fileurl")String fileurl,
@RequestParam(name="filename")String filename,
HttpServletResponse response){
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition","attachment;filename="+filename);
java.io.File file=new java.io.File(fileurl);
/*String filename = infile.getOriginalFilename() + "_" + DateUtil.format(new Date(), DatePattern.PURE_DATETIME_PATTERN);
String path = fileurl + FileUtil.FILE_SEPARATOR + fileInfo.getStoreId() + FileUtil.FILE_SEPARATOR + fileInfo.getSourceId() + FileUtil.FILE_SEPARATOR + filename;
// String path = fileurl + FileUtil.FILE_SEPARATOR + filename;
File file = FileUtil.touch(path);
try {
FileInputStream fis=new FileInputStream(file);
OutputStream os=response.getOutputStream();
byte[] buffer=new byte[1024];
int length;
while((length=fis.read(buffer))>0){
os.write(buffer,0,length);
}
fis.close();
os.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
infile.transferTo(file);
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
fileInfo.setName(filename);
fileInfo.setUrl(path);
fileInfo.setType(FileUtil.extName(file));
fileInfo.setSha256(SecureUtil.sha256(file).toUpperCase());
// 如果是预工单的话,可能是客户上传的文件
// fileInfo.setUploader();
fileService.save(fileInfo);
return ResultUtil.success();*/
}
public List<File> getFileList(Integer store_id,Integer source_id){
QueryWrapper<File> wrapper=new QueryWrapper<>();
if(store_id!=null)
wrapper.eq("store_id",store_id);
if(source_id!=null)
wrapper.eq("source_id",source_id);
List<File> fileList=fileSerrvice.list(wrapper);
return fileList;
@PostMapping("/uploadFile1")
public String uploadFile1(FileInfo fileInfo, @RequestParam(name = "files") MultipartFile[] files) throws IOException {
for (MultipartFile infile : files) {
String orgName = infile.getOriginalFilename();
String fileName = orgName.substring(0, orgName.lastIndexOf("."));
String fileExt = orgName.substring(orgName.lastIndexOf("."));
String filename = fileName + "_" + DateUtil.format(new Date(), "yyyyMMdd_HHmmss") + fileExt;
String path = fileurl + FileUtil.FILE_SEPARATOR + fileInfo.getStoreId() + FileUtil.FILE_SEPARATOR + fileInfo.getSourceId() + FileUtil.FILE_SEPARATOR + filename;
File file = FileUtil.touch(path);
infile.transferTo(file);
FileInfo tempFileInfo = new FileInfo();
tempFileInfo.setStoreId(fileInfo.getStoreId());
tempFileInfo.setSourceId(fileInfo.getSourceId());
tempFileInfo.setSourceType(fileInfo.getSourceType());
tempFileInfo.setName(filename);
tempFileInfo.setUrl(path);
tempFileInfo.setType(FileUtil.extName(file));
tempFileInfo.setSha256(SecureUtil.sha256(file).toUpperCase());
tempFileInfo.setUploader(fileInfo.getUploader());
fileService.save(tempFileInfo);
}
return "文件保存成功";
}
}
}
\ No newline at end of file
package vion.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;
import vion.Global;
import vion.enums.ResultEnum;
import vion.dto.InspectDTO;
import vion.model.Inspect;
import vion.model.Store;
import vion.service.IInspectSerrvice;
import vion.utils.ResultUtil;
import vion.service.IInspectService;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
@RestController
@RequestMapping(Global.BASE_URL)
@RequiredArgsConstructor
@Slf4j
public class InspectController {
@Autowired
private IInspectSerrvice inspectSerrvice;
private final IInspectService inspectService;
private final Converter converter;
@GetMapping("/inspects")
@ResponseBody
public Object getProductList(@RequestParam(name = "storeId",required=false)Integer store_id,
@RequestParam(name = "status",required=false)Integer status,
@RequestParam(name = "startdate",required=false)
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") Date startdate,
@RequestParam(name = "enddate",required=false)
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") Date enddate,
@RequestParam(name = "pageNum")Integer pageNum,
@RequestParam(name = "pageSize")Integer pageSize){
//pageNum当前页,pageSize每页条数
Page page= PageHelper.startPage(pageNum,pageSize);
QueryWrapper<Inspect> wrapper=new QueryWrapper<>();
if(store_id!=null)
wrapper.eq("store_id",store_id);
if(status!=null)
wrapper.eq("status",status);
if(startdate!=null)
wrapper.between("inspect_date",startdate,enddate);
List<Inspect> inspectList=inspectSerrvice.list(wrapper);
inspectList.sort(Comparator.comparing(Inspect::getId));
PageInfo pageInfo=new PageInfo<>(page);
pageInfo.setList(inspectList);
if (inspectList != null) {
return ResultUtil.success(pageInfo);
} else {
return ResultUtil.error(ResultEnum.SELECT_ERROR);
}
public Page<Inspect> getInspectList(InspectDTO data) {
return inspectService.getInspectList(data);
}
@GetMapping("/inspect")
@ResponseBody
public Object getProductByID(@RequestParam(name = "id")Integer id){
Inspect inspect=inspectSerrvice.getById(id);
if (inspect != null) {
return ResultUtil.success(inspect);
} else {
return ResultUtil.error(ResultEnum.SELECT_ERROR);
}
public Inspect getProductByID(@RequestParam(name = "id") Integer id) {
return inspectService.getById(id);
}
@PostMapping("/inspects")
@ResponseBody
public Object saveOrUpdate(@RequestBody Inspect data) {
try {
if(data.getId()==null){
inspectSerrvice.save(data);
return ResultUtil.success();
}else{
data.setModifyTime(new Date());
Inspect inspect=inspectSerrvice.saveAndReturn(data);
return ResultUtil.success(inspect);
}
}catch (Exception e) {
// return ResultUtil.error(ResultEnum.SELECT_ERROR);
return e.getMessage().toString();
}
public String saveOrUpdate(@RequestBody InspectDTO data) {
Inspect inspect = converter.convert(data, new Inspect());
return inspectService.saveOrUpdate(inspect) ? "成功" : "失败";
}
@PostMapping("/updateInspectStatus")
@ResponseBody
public Object UpdateStatus(@RequestBody Inspect data) {
Date current=new Date();
UpdateWrapper updateWrapper=new UpdateWrapper();
updateWrapper.eq("id",data.getId());
updateWrapper.set("status",data.getStatus());
updateWrapper.set("modify_time",current);
updateWrapper.set("audit_date",current);
updateWrapper.set("reviewer",data.getReviewer());
//审核状态为已完成的时候更新完成时间(0进行中、1待审核、2已完成、3、驳回)
if(data.getStatus()==2){
updateWrapper.set("finish_date",current);
}else{
updateWrapper.set("finish_date",null);
}
boolean result= inspectSerrvice.update(updateWrapper);
if(result){
return ResultUtil.success();
}else {
return ResultUtil.error(ResultEnum.SELECT_ERROR);
public String UpdateStatus(@RequestBody InspectDTO data) {
boolean result = inspectService.lambdaUpdate()
.eq(Inspect::getId, data.getId())
.set(Inspect::getStatus, data.getStatus())
.set(Inspect::getAuditTime, new Date())
.set(Inspect::getReviewer, data.getReviewer())
//审核状态为已完成的时候更新完成时间(0进行中、1待审核、2已完成、3、驳回)
.set(data.getStatus() == 2, Inspect::getFinishTime, new Date())
.update();
if (result) {
return "更新巡检状态成功";
} else {
return "更新巡检状态失败";
}
}
}
package vion.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import vion.Global;
import vion.enums.ResultEnum;
import vion.dto.ProductDTO;
import vion.model.Product;
import vion.model.Store;
import vion.service.IProductSerrvice;
import vion.service.IStoreSerrvice;
import vion.utils.ResultUtil;
import vion.service.IProductService;
import vion.vo.ProductVO;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@RestController
@RequestMapping(Global.BASE_URL)
@RequiredArgsConstructor
@Slf4j
public class ProductController {
@Autowired
private IProductSerrvice productSerrvice;
@Autowired
private IStoreSerrvice storeSerrvice;
private final IProductService productService;
private final Converter converter;
@GetMapping("/products")
@ResponseBody
public Object getProductList(@RequestParam(name = "accountId",required=false)Integer account_id,
@RequestParam(name = "storeId",required=false)Integer store_id,
@RequestParam(name = "name",required=false)String name,
@RequestParam(name = "brand",required=false)Integer brand,
@RequestParam(name = "functionary",required=false)Integer functionary,
@RequestParam(name = "pageNum")Integer pageNum,
@RequestParam(name = "pageSize")Integer pageSize){
//pageNum当前页,pageSize每页条数
Page page= PageHelper.startPage(pageNum,pageSize);
QueryWrapper<Product> wrapper=new QueryWrapper<>();
if(store_id!=null){
wrapper.eq("store_id",store_id);
}
if(account_id!=null)
wrapper.eq("account_id",account_id);
if(name!=null)
wrapper.eq("name",name);
if(brand!=null)
wrapper.eq("brand",brand);
if(functionary!=null)
wrapper.eq("functionary",functionary);
List<Product> productList=productSerrvice.list(wrapper);
List<Store> storeList=storeSerrvice.list();
List<ProductVO> productVOS=new ArrayList<>();
ProductVO productVO;
for(Product pro:productList){
productVO=new ProductVO();
productVO.setStoreName(storeList.stream().filter(store -> store.getId().equals(pro.getStoreId())).collect(Collectors.toList()).get(0).getName());
productVO.setId(pro.getId());
productVO.setStoreId(pro.getStoreId());
productVO.setMaterialNo(pro.getMaterialNo());
productVO.setName(pro.getName());
productVO.setFunctionary(pro.getFunctionary());
productVO.setBrand(pro.getBrand());
productVO.setProductCount(pro.getProductCount());
productVO.setProductPrice(pro.getProductPrice());
productVO.setProductTotalPrice(pro.getProductTotalPrice());
productVO.setProductSubtotal(pro.getProductSubtotal());
productVO.setCreateTime(pro.getCreateTime());
productVO.setModifyTime(pro.getModifyTime());
productVO.setRemark(pro.getRemark());
productVO.setAccountId(pro.getAccountId());
productVOS.add(productVO);
}
productVOS.sort(Comparator.comparing(ProductVO::getId));
PageInfo pageInfo=new PageInfo<>(page);
pageInfo.setList(productList);
if (pageInfo != null) {
return ResultUtil.success(pageInfo);
} else {
return ResultUtil.error(ResultEnum.SELECT_ERROR);
}
public Page<ProductVO> getProductList(ProductDTO productDTO) {
return productService.getProductList(productDTO);
}
@GetMapping("/product")
@ResponseBody
public Object getProductByID(@RequestParam(name = "projectId")Integer project_id){
Product product=productSerrvice.getById(project_id);
if (product != null) {
return ResultUtil.success(product);
} else {
return ResultUtil.error(ResultEnum.SELECT_ERROR);
}
public Product getProductByID(@RequestParam Long projectId) {
return productService.getById(projectId);
}
@PostMapping("/products")
@ResponseBody
public Object saveOrUpdate(@RequestBody Product data) {
try {
if(data.getId()==null){
productSerrvice.save(data);
return ResultUtil.success();
}else{
data.setModifyTime(new Date());
Product product=productSerrvice.saveAndReturn(data);
return ResultUtil.success(product);
}
}catch (Exception e) {
//return ResultUtil.error(ResultEnum.SELECT_ERROR);
return e.getMessage().toString();
}
public String saveOrUpdate(@RequestBody ProductDTO productDTO) {
Product data = converter.convert(productDTO, new Product());
return productService.saveOrUpdate(data) ? "成功" : "失败";
}
}
}
\ No newline at end of file
package vion.controller;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.IdUtil;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import vion.dto.ServiceOrderDTO;
import vion.model.Dictionary;
import vion.model.ServiceOrder;
import vion.service.IDictionaryService;
import vion.service.IServiceOrderService;
import vion.vo.ServiceOrderVO;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 服务单
*
* @author HlQ
* @date 2023/11/21
*/
@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
public class ServiceOrderController {
private final IServiceOrderService serviceOrderService;
private final IDictionaryService dictionaryService;
private final Converter converter;
@GetMapping("/order/{id}")
public ServiceOrder getOrderById(@PathVariable Long id) {
return serviceOrderService.getById(id);
}
@PostMapping("/order")
private Object save(@RequestBody ServiceOrderDTO serviceOrderDTO) {
Long count = serviceOrderService.lambdaQuery().eq(ServiceOrder::getTaskId, serviceOrderDTO.getTaskId()).count();
Assert.isFalse(count > 0, "该工单已存在服务单,不能重复创建!");
ServiceOrder serviceOrder = converter.convert(serviceOrderDTO, new ServiceOrder());
serviceOrder.setUnid(IdUtil.nanoId());
return serviceOrderService.save(serviceOrder) ? serviceOrder.getId() : "创建失败";
}
@PostMapping("/order/{id}")
private String update(@PathVariable Long id, @RequestBody ServiceOrderDTO serviceOrderDTO) {
ServiceOrder serviceOrder = converter.convert(serviceOrderDTO, new ServiceOrder());
serviceOrder.setId(id);
return serviceOrderService.updateById(serviceOrder) ? "更新成功" : "更新失败";
}
@DeleteMapping("/order/{id}")
private String remove(@PathVariable Long id) {
return serviceOrderService.removeById(id) ? "删除成功" : "删除失败";
}
@GetMapping("/order/sign/{unid}")
public ServiceOrderVO getOrderByUnid(@PathVariable String unid) {
// todo 字典加入缓存
List<Dictionary> dictionaryList = dictionaryService.lambdaQuery().eq(Dictionary::getType, "service_type").list();
Map<Integer, String> serviceTypeMap = dictionaryList.stream().collect(Collectors.toMap(Dictionary::getKey, Dictionary::getValue));
ServiceOrder order = serviceOrderService.lambdaQuery().eq(ServiceOrder::getUnid, unid).one();
ServiceOrderVO vo = converter.convert(order, new ServiceOrderVO());
vo.setServiceType(serviceTypeMap.get(order.getServiceType()));
return vo;
}
/**
* 签字专用更新接口
*
* @param unid 服务单unid
* @param serviceOrderDTO dto
* @return java.lang.String
*/
@PostMapping("/order/sign/{unid}")
public String updateByUnid(@PathVariable String unid, @RequestBody ServiceOrderDTO serviceOrderDTO) {
ServiceOrder serviceOrder = converter.convert(serviceOrderDTO, new ServiceOrder());
return serviceOrderService.lambdaUpdate().eq(ServiceOrder::getUnid, unid).update(serviceOrder) ? "提交成功" : "提交失败";
}
@GetMapping("/order/pushWechat")
public String sendOrder(Long id) {
return serviceOrderService.sendOrder(id);
}
}
package vion.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.bouncycastle.util.test.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import vion.Global;
import vion.enums.ResultEnum;
import vion.model.File;
import vion.model.Store;
import vion.model.TaskTemp;
import vion.service.IFileSerrvice;
import vion.service.ITaskTempSerrvice;
import vion.utils.ResultUtil;
import vion.dto.TaskTempDTO;
import vion.service.ITaskTempService;
import vion.vo.TaskTempVO;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
@RestController
@RequestMapping(Global.BASE_URL)
@RequiredArgsConstructor
@Slf4j
public class TaskTempController {
@Autowired
private ITaskTempSerrvice taskTempSerrvice;
@Autowired
private IFileSerrvice fileSerrvice;
@Autowired
private FileController fileController;
private final ITaskTempService taskTempService;
@GetMapping("/taskTemps")
@ResponseBody
public Object getTaskTempList(@RequestParam(name = "storeName",required=false)String store_name,
@RequestParam(name = "storeId",required=false)Integer store_id,
@RequestParam(name = "startdate",required=false)
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") Date startdate,
@RequestParam(name = "enddate",required=false)
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") Date enddate,
@RequestParam(name = "status",required=false)Integer status,
@RequestParam(name = "pageNum")Integer pageNum,
@RequestParam(name = "pageSize")Integer pageSize){
//pageNum当前页,pageSize每页条数
Page page= PageHelper.startPage(pageNum,pageSize);
QueryWrapper<TaskTemp> wrapper=new QueryWrapper<>();
if(store_id!=null)
wrapper.eq("store_id",store_id);
if(store_name!=null)
wrapper.like("store_name",store_name);
if(status!=null)
wrapper.eq("status",status);
if(startdate!=null)
wrapper.between("repair_date",startdate,enddate);
List<TaskTemp> taskTempList= taskTempSerrvice.list(wrapper);
taskTempList.sort(Comparator.comparing(TaskTemp::getId));
PageInfo pageInfo=new PageInfo<>(page);
pageInfo.setList(taskTempList);
if (pageInfo != null) {
return ResultUtil.success(pageInfo);
} else {
return ResultUtil.error(ResultEnum.SELECT_ERROR);
}
public Page<TaskTempVO> getTaskTempList(TaskTempDTO data) {
return taskTempService.getTaskTempList(data);
}
@GetMapping("/taskTemp")
@ResponseBody
public Object getTaskTempByID(@RequestParam(name = "id")Integer id){
TaskTemp taskTemp = taskTempSerrvice.getById(id);
TaskTempVO taskTempVO=new TaskTempVO();
List<File> files=fileController.getFileList(taskTemp.getStoreId(),taskTemp.getId());
taskTempVO.setId(taskTemp.getId());
taskTempVO.setStoreName(taskTemp.getStoreName());
taskTempVO.setRepairDate(taskTemp.getRepairDate());
taskTempVO.setFaultDescription(taskTemp.getFaultDescription());
taskTempVO.setRepairPeople(taskTemp.getRepairPeople());
taskTempVO.setRepairPhone(taskTemp.getRepairPhone());
taskTempVO.setStatus(taskTemp.getStatus());
taskTempVO.setCreateTime(taskTemp.getCreateTime());
taskTempVO.setFileList(files);
if (taskTempVO != null) {
return ResultUtil.success(taskTempVO);
} else {
return ResultUtil.error(ResultEnum.SELECT_ERROR);
}
public TaskTempVO getTaskTempById(Long id) {
return taskTempService.getTaskTempById(id);
}
@PostMapping("/taskTemps")
@ResponseBody
public Object saveOrUpdateTaskTemp(@RequestBody TaskTempVO data) {
try {
TaskTemp taskTemp=new TaskTemp();
taskTemp.setStoreName(data.getStoreName());
taskTemp.setRepairPeople(data.getRepairPeople());
taskTemp.setRepairPhone(data.getRepairPhone());
taskTemp.setRepairDate(data.getRepairDate());
taskTemp.setFaultDescription(data.getFaultDescription());
TaskTemp saveTaskTemp= taskTempSerrvice.saveAndReturn(taskTemp);
if(saveTaskTemp!=null){
if(data.getFileList()!=null){
File file;
for(File fileModel:data.getFileList()){
file=new File();
file.setId(fileModel.getId());
file.setStoreId(0);
file.setSourceId(saveTaskTemp.getId());
file.setSourceType(2);//1项目、2工单预处理,3工单操作,4巡检
file.setName(fileModel.getName());
file.setUrl(fileModel.getUrl());
file.setType(fileModel.getType());
fileSerrvice.saveOrUpdate(file);
}
}
}
return ResultUtil.success();
}catch (Exception e) {
//return ResultUtil.error(ResultEnum.SELECT_ERROR);
return e.getMessage();
}
@PostMapping("/taskTemp")
public String saveOrUpdateTaskTemp(TaskTempDTO data) {
return taskTempService.saveOrUpdTaskTemp(data);
}
@PostMapping("/updateTaskTempStatus")
@ResponseBody
public Object updateStoreStage(@RequestBody TaskTemp taskTemp) {
//更新预处理工单状态
UpdateWrapper updateWrapper=new UpdateWrapper();
updateWrapper.eq("id", taskTemp.getId());
updateWrapper.set("status",2);//状态(1待确认、2已确认)
updateWrapper.set("operator",taskTemp.getOperator());
updateWrapper.set("store_id",taskTemp.getStoreId());
updateWrapper.set("modify_time",new Date());
boolean result= taskTempSerrvice.update(updateWrapper);
//根据预处理工单跟新附件的门店ID
fileSerrvice.lambdaUpdate()
.setSql("store_id="+taskTemp.getStoreId())
.eq(File::getSourceId,taskTemp.getId())
.update();
if(result){
return ResultUtil.success();
}else {
return ResultUtil.error(ResultEnum.SELECT_ERROR);
}
}
}
package vion.cron;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import vion.ding.DingMod;
import vion.model.Task;
import vion.model.User;
import vion.service.ITaskService;
import vion.service.IUserService;
import java.util.List;
/**
* @author HlQ
* @date 2023/11/13
*/
@Component
@RequiredArgsConstructor
@Slf4j
public class TaskRunner {
private final IUserService userService;
private final ITaskService taskService;
private final DingMod dingMod;
@Scheduled(cron = "0 0 17 * * ?")
void pushUndoneTask() {
log.info("开始推送未完成工单");
List<Task> taskList = taskService.list(Wrappers.<Task>lambdaQuery().notIn(Task::getStatus, 3, 5));
// todo 需要异步发送吗?
taskList.forEach(task -> {
Long activeUser = task.getActiveUser();
User user = userService.lambdaQuery().eq(User::getId, activeUser).one();
dingMod.sendMessage(buildMsg(user));
});
log.info("推送未完成工单完成");
}
JSONObject buildMsg(User user) {
JSONObject jsonObj = new JSONObject();
jsonObj.set("agent_id", 2358374016L);
jsonObj.set("userid_list", user.getUserid());
JSONObject msg = new JSONObject();
JSONObject content = new JSONObject();
content.set("title", "请查看您未完成的工单~_~");
content.set("markdown", "请查看您未完成的工单" +
" \n 发送时间:" + DateUtil.now());
content.set("btn_orientation", "1");
JSONArray jsonArray = new JSONArray();
jsonArray.add(new JSONObject().set("title", "查看详情").set("action_url", "https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingkrzwks0jpi2di3uo&response_type=code&scope=snsapi_auth&state=STATE&redirect_uri=https%3A%2F%2Fyunwei.vionyun.com%3A8443%2Fyunwei%2Fapi%2Fding%2Fcallback%2Finside%3FuserId%3D" + user.getId()));
content.set("btn_json_list", jsonArray);
msg.set("msgtype", "action_card");
msg.set("action_card", content);
jsonObj.set("msg", msg);
return jsonObj;
}
}
\ No newline at end of file
package vion.ding;
import cn.hutool.core.util.StrUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.bean.WxOAuth2UserInfo;
import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;
/**
* @author HlQ
* @date 2023/11/21
*/
@Component
@RequiredArgsConstructor
@Slf4j
public class WechatMod {
private final WxMpService wxMpService;
/**
* 微信扫码获取用户 openid
*
* @param code
* @return java.lang.Object
*/
public Object wechatCallback(String code) {
try {
WxOAuth2AccessToken accessToken = wxMpService.getOAuth2Service().getAccessToken(code);
WxOAuth2UserInfo wxMpUser = wxMpService.getOAuth2Service().getUserInfo(accessToken, null);
return wxMpUser.getOpenid();
} catch (WxErrorException e) {
log.error("调用微信接口异常!", e);
}
return new ModelAndView("weChatError");
}
/**
* 生成微信网页授权链接
* @param taskTempId 预工单 id
* @return java.lang.String
*/
public String genCodeUrl(Long taskTempId) {
String url = StrUtil.format("https://yunwei.vionyun.com/yunwei/api/wechat/callback?taskTempId={}", taskTempId);
return wxMpService.getOAuth2Service().buildAuthorizationUrl(url, WxConsts.OAuth2Scope.SNSAPI_USERINFO, null);
}
public String sendMsg(String templateId, String openId, List<WxMpTemplateData> wxMpTemplateDataList, String url) {
try {
WxMpTemplateMessage templateMessage = WxMpTemplateMessage.builder()
.toUser(openId)
.templateId(templateId)
.data(wxMpTemplateDataList)
.url(url)
.build();
String s = wxMpService.getTemplateMsgService().sendTemplateMsg(templateMessage);
log.info("微信消息推送成功,msgid:{}", s);
return "微信公众号消息推送成功";
} catch (WxErrorException e) {
log.error("调用微信接口发送模板消息异常!", e);
}
return "微信公众号消息推送失败";
}
}
package vion.dto;
import lombok.Getter;
import lombok.Setter;
/**
* @author HlQ
* @date 2023/11/24
*/
@Getter
@Setter
public class BaseDTO {
private Integer pageNum = 1;
private Integer pageSize = 10;
}
package vion.dto;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class DictionaryDTO extends BaseDTO {
private Long id;
private String type;
private Integer key;
private String value;
private String remark;
}
package vion.dto;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class DictionaryTypeDTO extends BaseDTO {
private Long id;
private String name;
private String type;
private String remark;
}
package vion.dto;
import lombok.Getter;
import lombok.Setter;
/**
* @author HlQ
* @date 2023/11/25
*/
@Getter
@Setter
public class DingDTO {
/** 微信拼接的两个 code 参数 */
private String authCode;
private String code;
/** 项目id */
private Long storeId;
/** 工单id */
private Long taskId;
/** 预工单id */
private Long taskTempId;
/** 用户id */
private Long userId;
}
package vion.dto;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class FileInfoDTO extends BaseDTO {
private Long id;
/** 门店id */
private Long storeId;
/** 文件扩展名 */
private String type;
/** 文件来源(1项目、2工单预处理,3工单操作,4巡检) */
private Integer sourceType;
/** 文件来源id */
private Long sourceId;
/** 文件名称 */
private String name;
/** 文件地址 */
private String url;
/** 备注 */
private String remark;
/** sha256 */
private String sha256;
/** 上传人 */
private String uploader;
}
package vion.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Getter
@Setter
public class InspectDTO extends BaseDTO {
/** 自增列 */
private Long id;
/** 门店id */
private Long storeId;
/** 巡检时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date inspectTime;
/** 巡检方式(0远程、1现场) */
private Integer type;
/** 状态(0进行中、1待审核、2已完成、3、驳回) */
private Integer status;
/** 巡检人 */
private Integer inspectUser;
/** 审核人 */
private Integer reviewer;
/** 巡检时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date finishTime;
/** 审核时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date auditTime;
/** 备注 */
private String remark;
/** 集团id */
private Long accountId;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startdate;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date enddate;
}
package vion.dto;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class ProductDTO extends BaseDTO {
private Long id;
/** 物料编号 */
private String materialNo;
/** 门店id */
private Long storeId;
/** 门店名称 */
private String storeName;
/** 产品名称 */
private String name;
/** 产品型号 */
private Integer functionary;
/** 品牌 */
private Integer brand;
/** 订货数量 */
private Integer productCount;
/** 订货单价 */
private Float productPrice;
/** 定后价小计(单价乘以数量) */
private Float productSubtotal;
/** 订货总价 */
private Float productTotalPrice;
/** 备注 */
private String remark;
/** 集团id */
private Long accountId;
}
package vion.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import java.util.Date;
/**
* @author HlQ
* @date 2023/11/23
*/
@Getter
@Setter
public class ServiceOrderDTO extends BaseDTO {
/** 项目名称 */
private String projectName;
/** 报修人 */
private String submitter;
/** 报修人手机号码 */
private String submitPhone;
/** 报修时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date submitTime;
/** 维修人 */
private String repairPeople;
/** 维修人手机号码*/
private String repairPhone;
/** 部门 */
private String dept;
/** 服务方式(1.电话支持 2.远程服务 3.现场服务) */
private Integer serviceType;
/** 耗时 */
private Double time;
/** 故障内容 */
private String faultContent;
/** 维修结果 */
private String repairRes;
/** 客户评价 */
private String review;
/** 工单id */
private Long taskId;
/** 服务单状态 */
private Integer state;
/** 五星好评 */
private Integer stars;
/** 签字图片base64 */
private String signPic;
/** 签字时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date signTime;
/** 完成时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date finishTime;
}
package vion.dto;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
@Data
public class StatusDTO {
/** 门店id */
private Long storeId;
/** 阶段 */
private Integer projectStage;
/** 文件来源 */
private Integer sourceType;
/** 来源id */
private Long sourceId;
/** 文件类型 */
private Integer type;
/** 名称 */
private String name;
/** 地址 */
private String url;
private MultipartFile[] files;
}
package vion.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* 门店信息
*/
@Getter
@Setter
public class StoreDTO extends BaseDTO {
private Long id;
private String storenum;
/** 门店名称 */
private String name ;
/** 流水号 */
private String number;
/** 合同编码 */
private String contractCode;
/** 合同金额 */
private Float amount;
/** 签订日期 */
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date orderdate;
/** 销售人 */
private Integer salesperson;
/** 质保期 */
private Integer warrantyPeriod;
/** 客户姓名 */
private String customerName;
/** 实施类型:0纯供货、1供货+安装、3续保、4维修 */
private Integer implementType;
/** 项目状态:0待确认、1进行中、2已完成、3挂起 */
private Integer projectState;
/** 联系人(多个联系人逗号隔开) */
private String contacts;
/** 创建者 */
private Long createUser;
/** 修改者 */
private Long modifyUser;
/** 备注 */
private String remark;
/** 项目阶段 */
private Integer projectStage;
/** 集团id */
private Long accountId;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startdate;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date enddate;
}
package vion.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.multipart.MultipartFile;
import java.util.Date;
@Getter
@Setter
public class TaskDTO extends BaseDTO {
private Long id;
/** 门店id */
private Long storeId;
/** 报修日期 */
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date repairTime;
/** 故障类型 */
private Integer faultType;
/** 故障说明 */
private String faultDescription;
/** 报修人 */
private String repairPeople;
/** 报修人联系方式 */
private String repairPhone;
/** 状态:0待确认1进行中2已完成3挂起 */
private Integer status;
/** 解决日期 */
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date solveDate;
/** 故障原因 */
private String faultReason;
/** 解决措施:0产品BUG、1使用问题、2需求问题 */
private Integer solveType;
/** 解决故障描述 */
private String solveDescription;
/** 创建者 */
private Long createUser;
/** 当前处理人 */
private Long activeUser;
/** 截止日期 */
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date expDate;
/** 备注 */
private String remark;
/** 集团id */
private Long accountId;
private String uuid;
/** 预工单id */
private Long tasktempId;
private MultipartFile[] files;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startdate;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date enddate;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date curDate;
}
package vion.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.multipart.MultipartFile;
import vion.model.FileInfo;
import java.util.Date;
import java.util.List;
@Getter
@Setter
public class TaskTempDTO extends BaseDTO {
private Long id;
private Long storeId;
/** 项目名称 */
private String storeName;
/** 报修日期 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date repairTime;
/** 故障说明 */
private String faultDescription;
/** 报修人 */
private String repairPeople;
/** 联系方式 */
private String repairPhone;
/** 状态(1待确认、2已确认) */
private Integer status;
/** 附件信息 */
private List<FileInfo> fileList;
private String remark;
private MultipartFile[] files;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startdate;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date enddate;
}
package vion.interceptor;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.Opt;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import cn.hutool.json.JSONObject;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import vion.Global;
import vion.enums.ResultEnum;
import vion.model.User;
import vion.service.IUserSerrvice;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
public class Interceptor extends HandlerInterceptorAdapter {
@Component
public class Interceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
String url = request.getRequestURI();
System.out.println("拦截器");
if(url.indexOf("login") >= 0){
if (url.indexOf("login") >= 0) {
return true;
}
User user= Global.USERNAME_MAP.get(request.getHeader("userid"));
if(user==null){
User user = Opt.ofBlankAble(request.getHeader("token")).map(Global.USERNAME_MAP::get).orElse(null);
if (user == null) {
response.reset();
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json;charset=UTF-8");
PrintWriter pw = response.getWriter();
JSONObject jsonObject = new JSONObject();
jsonObject.put("msg_code", ResultEnum.ATOKEN_ERROR.getCode());
jsonObject.put("msg_info", "请先登陆再访问!");
pw.write(JSON.toJSONString(jsonObject));
jsonObject.set("code", ResultEnum.ATOKEN_ERROR.getCode());
jsonObject.set("msg", "请先登陆再访问!");
pw.write(jsonObject.toString());
pw.flush();
pw.close();
return false;
} else {
request.setAttribute("start", System.currentTimeMillis());
return true;
}
request.setAttribute("userid", user.getUserid());
request.setAttribute("start", System.currentTimeMillis());
return super.preHandle(request, response, handler);
}
}
package vion.interceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import javax.annotation.Resource;
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
@Bean
public Interceptor interceptor() {
return new Interceptor();
}
@Override
public void addInterceptors(InterceptorRegistry registry){
@Resource
private Interceptor interceptor;
registry.addInterceptor(interceptor()).addPathPatterns("/api/**").excludePathPatterns("/api/login")
.excludePathPatterns("/error");//.excludePathPatterns("/api/downLoadFile");
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(interceptor)
.addPathPatterns("/api/**")
.excludePathPatterns("/api/taskTemp", "/api/upLoadFile", "/api/ding/callback/**", "/api/wechat/**", "/error")
.excludePathPatterns("/api/order/sign/*");
}
}
package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import vion.model.Account;
@Mapper
public interface AccountMapper extends BaseMapper<Account> {
}
package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import vion.model.Account;
import vion.model.Address;
@Mapper
public interface AddressMapper extends BaseMapper<Address> {
}
package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import vion.model.Dept;
/**
* @author HlQ
* @date 2023/11/10
*/
public interface DeptMapper extends BaseMapper<Dept> {
}
package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import vion.model.Address;
import vion.model.Dictionary;
@Mapper
public interface DictionaryMapper extends BaseMapper<Dictionary> {
}
package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import vion.model.Address;
import vion.model.DictionaryType;
@Mapper
public interface DictionaryTypeMapper extends BaseMapper<DictionaryType> {
}
package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import vion.model.Address;
import vion.model.FaultLog;
@Mapper
public interface FaultLogMapper extends BaseMapper<FaultLog> {
}
package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import vion.model.Address;
import vion.model.File;
@Mapper
public interface FileMapper extends BaseMapper<File> {
import vion.model.FileInfo;
public interface FileMapper extends BaseMapper<FileInfo> {
}
package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import vion.model.Address;
import vion.model.Inspect;
@Mapper
public interface InspectMapper extends BaseMapper<Inspect> {
}
package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import vion.model.Address;
import vion.model.Product;
@Mapper
public interface ProductMapper extends BaseMapper<Product> {
}
package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import vion.model.ServiceOrder;
/**
* @author HlQ
* @date 2023/11/21
*/
public interface ServiceOrderMapper extends BaseMapper<ServiceOrder> {
}
package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import vion.model.Product;
import vion.model.Store;
@Mapper
public interface StoreMapper extends BaseMapper<Store> {
}
package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import vion.model.Product;
import vion.model.Task;
@Mapper
public interface TaskMapper extends BaseMapper<Task> {
}
package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import vion.model.TaskTemp;
@Mapper
public interface TaskTempMapper extends BaseMapper<TaskTemp> {
}
package vion.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import vion.model.Product;
import vion.model.User;
@Mapper
public interface UserMapper extends BaseMapper<User> {
}
package vion.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
/**
* 集团信息
*/
import java.util.Date;
@Data
@TableName(value="tbl_account_info")
public class Account {
/** 自增列 */
@TableId(value = "id", type = IdType.AUTO)
private Integer id;//自增列
private Long id;
private String name;//名称
/** 名称 */
private String name;
private Date createTime;//创建时间
/** 创建时间 */
@TableField(value = "create_time", fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
private Date modifyTime;//修改时间
/** 修改时间 */
@TableField(value = "modify_time", fill = FieldFill.INSERT_UPDATE)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date modifyTime;
private String remark;//备注
/** 备注 */
private String remark;
}
......@@ -12,8 +12,8 @@ import lombok.Data;
@TableName(value="tbl_address_info")
public class Address {
@TableId(value = "id", type = IdType.AUTO)
private Integer id;//自增列
private Integer storeId;//门店编码(外键)
private Long id;//自增列
private Long storeId;//门店编码
private String consigneeName;//收货名称
private String consigneePhone;//收货手机号
private String consigneeAddress;//收货地址
......
package vion.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
@Data
@TableName(value="tbl_dept_info")
public class Dept {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
private Long deptId;
private String deptName;
private Long parentId;
@TableField(value = "create_time", fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
@TableField(value = "modify_time", fill = FieldFill.INSERT_UPDATE)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date modifyTime;
}
\ No newline at end of file
package vion.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.github.linpeilie.annotations.AutoMapper;
import io.github.linpeilie.annotations.AutoMappers;
import lombok.Data;
import vion.dto.DictionaryDTO;
import java.util.Date;
@Data
@TableName(value="tbl_dictionary_info")
@AutoMappers({
@AutoMapper(target = DictionaryDTO.class),
})
public class Dictionary {
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
private Long id;
private String type;
private Integer key;
private String value;
private String remark;
/** 创建时间 */
@TableField(value = "create_time", fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
/** 更新时间 */
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
}
package vion.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.github.linpeilie.annotations.AutoMapper;
import io.github.linpeilie.annotations.AutoMappers;
import lombok.Data;
import vion.dto.DictionaryTypeDTO;
import java.util.Date;
@Data
@TableName(value="tbl_dictionary_type")
@AutoMappers({
@AutoMapper(target = DictionaryTypeDTO.class),
})
public class DictionaryType {
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
private Long id;
private String name;
private String type;
private String remark;
/** 创建时间 */
@TableField(value = "create_time", fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
/** 更新时间 */
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
}
package vion.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import vion.vo.FaultLogVO;
import java.util.Date;
......@@ -10,13 +13,24 @@ import java.util.Date;
*/
@Data
@TableName(value="tbl_fault_log")
@AutoMapper(target = FaultLogVO.class)
public class FaultLog {
/** 自增列 */
@TableId(value = "id", type = IdType.AUTO)
private Integer id;//自增列
private Integer storeId;//门店id(外键)
private Integer taskId;//工单id(外键)
private Integer operator;//操作者
private String content;//操作内容
private Date createTime;//创建时间
private String remark;//备注
private Long id;
/** 门店id */
private Long storeId;
/** 工单id */
private Long taskId;
/** 操作者 */
private Long operator;
/** 操作内容 */
private String content;
/** 创建时间 */
@TableField(value = "create_time", fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
/** 备注 */
private String remark;
}
package vion.model;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.util.Date;
/**
* 文件信息
*/
@Data
@TableName(value="tbl_file_info")
public class File {
@TableId(value = "id", type = IdType.AUTO)
private Integer id;//自增列
private Integer storeId;//门店id(外键)
private Integer type;//文件类型(1图片 2文件)
private Integer sourceType;//文件来源(项目、工单预处理,工单操作,巡检)
private Integer sourceId;//文件来源id
private String name;//文件名称
private String url;//文件地址
private Date createTime;//创建时间
private String remark;//备注
}
package vion.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.github.linpeilie.annotations.AutoMapper;
import io.github.linpeilie.annotations.AutoMappers;
import lombok.Data;
import vion.dto.FileInfoDTO;
import java.util.Date;
/**
* 文件信息
*/
@Data
@TableName(value="tbl_file_info")
@AutoMappers({
@AutoMapper(target = FileInfoDTO.class),
})
public class FileInfo {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/** 门店id */
private Long storeId;
/** 文件扩展名 */
private String type;
/** 文件来源(1项目、2工单预处理,3工单操作,4巡检) */
private Integer sourceType;
/** 文件来源id */
private Long sourceId;
/** 文件名称 */
private String name;
/** 文件地址 */
private String url;
/** 创建时间 */
@TableField(value = "create_time", fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
/** 备注 */
private String remark;
/** sha256 */
private String sha256;
/** 上传人 */
private String uploader;
}
package vion.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.github.linpeilie.annotations.AutoMapper;
import io.github.linpeilie.annotations.AutoMappers;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import vion.dto.InspectDTO;
import java.util.Date;
......@@ -9,18 +14,57 @@ import java.util.Date;
* 巡检信息
*/
@Data
@TableName(value="tbl_inspect_info")
@TableName(value = "tbl_inspect_info")
@AutoMappers({
@AutoMapper(target = InspectDTO.class),
})
public class Inspect {
/** 自增列 */
@TableId(value = "id", type = IdType.AUTO)
private Integer id;//自增列
private Integer storeId;//门店id(外键)
private Date inspectDate;//巡检日期
private Integer type;//巡检方式(0远程、1现场)
private Integer status;//状态(0进行中、1待审核、2已完成、3、驳回)
private Integer inspectUser;//巡检人
private Integer reviewer;//审核人
private Date finishDate;//完成日期
private Date createTime;//创建时间
private Date modifyTime;//修改时间
private String remark;//备注
private Long id;
/** 门店id */
private Long storeId;
/** 巡检时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@OrderBy
private Date inspectTime;
/** 巡检方式(0远程、1现场) */
private Integer type;
/** 状态(0进行中、1待审核、2已完成、3、驳回) */
private Integer status;
/** 巡检人 */
private Integer inspectUser;
/** 审核人 */
private Integer reviewer;
/** 巡检时间 */
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date finishTime;
/** 审核时间 */
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date auditTime;
/** 创建时间 */
@TableField(value = "create_time", fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
/** 修改时间 */
@TableField(value = "modify_time", fill = FieldFill.INSERT_UPDATE)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date modifyTime;
/** 备注 */
private String remark;
/** 集团id */
private Long accountId;
@TableField(exist = false)
private String accountName;
@TableField(exist = false)
private String storeName;
}
package vion.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.github.linpeilie.annotations.AutoMapper;
import io.github.linpeilie.annotations.AutoMappers;
import lombok.Data;
import vion.dto.ProductDTO;
import vion.vo.ProductVO;
import java.util.Date;
......@@ -10,20 +15,44 @@ import java.util.Date;
*/
@Data
@TableName(value="tbl_product_info")
@AutoMappers({
@AutoMapper(target = ProductVO.class),
@AutoMapper(target = ProductDTO.class),
})
public class Product {
/** 自增列 */
@TableId(value = "id", type = IdType.AUTO)
private Integer id;//自增列
private String materialNo;//物料编号
private Integer storeId;//门店id(外键)
private String name;//产品名称
private Integer functionary;//产品型号
private Integer brand;//品牌
private Integer productCount;//订货数量
private Float productPrice;//订货单价
private Float productSubtotal;//定后价小计(单价乘以数量)
private Float productTotalPrice;//订货总价
private Date createTime;//创建时间
private Date modifyTime;//修改时间
private String remark;//备注
private Integer accountId;//集团id
private Long id;
/** 物料编号 */
private String materialNo;
/** 门店id */
private Long storeId;
/** 产品名称 */
private String name;
/** 产品型号 */
private Integer functionary;
/** 品牌 */
private Integer brand;
/** 订货数量 */
private Integer productCount;
/** 订货单价 */
private Float productPrice;
//定后价小计(单价乘以数** ) */
private Float productSubtotal;
/** 订货总价 */
private Float productTotalPrice;
/** 创建时间 */
@TableField(value = "create_time", fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
/** 修改时间 */
@TableField(value = "modify_time", fill = FieldFill.INSERT_UPDATE)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date modifyTime;
/** 备注 */
private String remark;
/** 集团id */
private Long accountId;
}
package vion.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.github.linpeilie.annotations.AutoMapper;
import io.github.linpeilie.annotations.AutoMappers;
import lombok.Data;
import vion.dto.ServiceOrderDTO;
import vion.vo.ServiceOrderVO;
import java.util.Date;
@Data
@TableName("tbl_service_order")
@AutoMappers({
@AutoMapper(target = ServiceOrderVO.class),
@AutoMapper(target = ServiceOrderDTO.class),
})
public class ServiceOrder {
@TableId(type = IdType.AUTO)
private Long id;
/** 项目名称 */
private String projectName;
/** 报修人 */
private String submitter;
/** 报修人手机号码 */
private String submitPhone;
/** 报修时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date submitTime;
/** 维修人 */
private String repairPeople;
/** 维修人手机号码*/
private String repairPhone;
/** 部门 */
private String dept;
/** 服务方式(1.电话支持 2.远程服务 3.现场服务) */
private Integer serviceType;
/** 耗时 */
private Double time;
/** 故障内容 */
private String faultContent;
/** 维修结果 */
private String repairRes;
/** 客户评价 */
private String review;
/** 工单id */
private Long taskId;
/** 服务单状态 */
private Integer state;
/** 创建时间 */
@TableField(value = "create_time", fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
/** 更新时间 */
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
/** 五星好评 */
private Integer stars;
/** 签字图片base64 */
private String signPic;
/** 签字时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date signTime;
/** 完成时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date finishTime;
/** 唯一id */
private String unid;
}
package vion.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.github.linpeilie.annotations.AutoMapper;
import io.github.linpeilie.annotations.AutoMappers;
import lombok.Data;
import vion.dto.StoreDTO;
import vion.vo.StoreVO;
import java.util.Date;
......@@ -10,26 +15,56 @@ import java.util.Date;
*/
@Data
@TableName(value="tbl_store_info")
@AutoMappers({
@AutoMapper(target = StoreVO.class),
@AutoMapper(target = StoreDTO.class),
})
public class Store {
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
private Long id;
private String storenum;
private String name ;// 门店名称
private String number;// 流水号
private String contractCode;//合同编码
private Float amount;// 合同金额
private Date orderdate;//签订日期
private Integer salesperson;//销售人
private Integer warrantyPeriod;//质保期
private String customerName;//客户姓名
private Integer implementType;//实施类型:0纯供货、1供货+安装、3续保、4维修
private Integer projectState;//项目状态:0待确认、1进行中、2已完成、3挂起
private String contacts;//联系人(多个联系人逗号隔开)
private Integer createUser;//创建者
private Integer modifyUser;//修改者
private Date createTime;//创建时间
private Date modifyTime;//修改时间
private String remark;//备注
private Integer projectStage;//项目阶段
private Integer accountId;//集团id
/** 门店名称 */
private String name;
/** 流水号 */
private String number;
/** 合同编码 */
private String contractCode;
/** 合同金额 */
private Float amount;
/** 签订日期 */
private Date orderdate;
/** 销售人 */
private Integer salesperson;
/** 质保期 */
private Integer warrantyPeriod;
/** 客户姓名 */
private String customerName;
/** 实施类型:0纯供货、1供货+安装、3续保、4维修 */
private Integer implementType;
/** 项目状态:0待确认、1进行中、2已完成、3挂起 */
private Integer projectState;
/** 联系人(多个联系人逗号隔开) */
private String contacts;
/** 创建者 */
private Long createUser;
/** 修改者 */
private Long modifyUser;
/** 创建时间 */
@TableField(value = "create_time", fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@OrderBy
private Date createTime;
/** 修改时间 */
@TableField(value = "modify_time", fill = FieldFill.INSERT_UPDATE)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date modifyTime;
/** 备注 */
private String remark;
/** 项目阶段 */
private Integer projectStage;
/** 集团id */
private Long accountId;
}
package vion.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.github.linpeilie.annotations.AutoMapper;
import io.github.linpeilie.annotations.AutoMappers;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import vion.dto.TaskDTO;
import vion.vo.TaskVO;
import java.util.Date;
@Data
@TableName(value="tbl_task_info")
@AutoMappers({
@AutoMapper(target = TaskVO.class),
@AutoMapper(target = TaskDTO.class),
})
public class Task {
/** 自增列 */
@TableId(value = "id", type = IdType.AUTO)
private Integer id;//自增列
private Integer storeId;//门店id(外键)
private Date repairDate;//报修日期
private Integer faultType;//故障类型
private String faultDescription;//故障说明
private Integer repairPeople;//报修人
private String repairPhone;//报修人联系方式
private Integer status;//状态:0待确认1进行中2已完成3挂起
private Date solveDate;//解决日期
private String faultReason;//故障原因
private Integer solveType;//解决措施:0产品BUG、1使用问题、2需求问题
private String solveDescription;//解决故障描述
private Integer createUser;//创建者
private Integer activeUser;//当前处理人
private Date createTime;//创建时间
private Date modifyTime;//修改时间
private String remark;//备注
private Integer accountId;//集团id
private Long id;
/** 门店id */
private Long storeId;
/** 报修日期 */
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@OrderBy(sort = 2)
private Date repairTime;
/** 故障类型 */
private Integer faultType;
/** 故障说明 */
private String faultDescription;
/** 报修人 */
private String repairPeople;
/** 报修人联系方式 */
private String repairPhone;
/** 状态 */
@OrderBy(asc = true, sort = 1)
private Integer status;
/** 解决日期 */
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date solveDate;
/** 故障原因 */
private String faultReason;
/** 解决措施:0产品BUG、1使用问题、2需求问题 */
private Integer solveType;
/** 解决故障描述 */
private String solveDescription;
/** 创建者 */
private Long createUser;
/** 当前处理人 */
private Long activeUser;
/** 截止日期 */
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date expDate;
/** 创建时间 */
@TableField(value = "create_time", fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
/** 修改时间 */
@TableField(value = "modify_time", fill = FieldFill.INSERT_UPDATE)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date modifyTime;
/** 备注 */
private String remark;
/** 集团id */
private Long accountId;
private String uuid;
/** 预工单id */
private Long taskTempId;
}
package vion.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.github.linpeilie.annotations.AutoMapper;
import io.github.linpeilie.annotations.AutoMappers;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import vion.dto.TaskTempDTO;
import vion.vo.TaskTempVO;
import java.util.Date;
@Data
@TableName(value="tbl_task_temp")
@AutoMappers({
@AutoMapper(target = TaskTempVO.class),
@AutoMapper(target = TaskTempDTO.class),
})
public class TaskTemp {
@TableId(type= IdType.AUTO)
private Integer id;//自增列
private Integer storeId;//项目名称
private String storeName;//项目名称
private Date repairDate;//报修日期
private String faultDescription;//故障说明
private String repairPeople;//报修人
private String repairPhone;//联系方式
private Integer status;//状态(1待确认、2已确认)
private Integer operator;//操作人
private Date createTime;//创建时间
private Date modifyTime;//修改时间
private String remark;//备注
private Long id;
/** 项目id */
private Long storeId;
/** 项目名称 */
private String storeName;
/** 报修时间 */
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@OrderBy(sort = 2)
private Date repairTime;
/** 故障说明 */
private String faultDescription;
/** 报修人 */
private String repairPeople;
/** 联系方式 */
private String repairPhone;
/** 状态(1待确认、2进行中、3已确认) */
@OrderBy(asc = true, sort = 1)
private Integer status;
/** 操作人 */
private Long operator;
/** 创建时间 */
@TableField(value = "create_time", fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
/** 修改时间 */
@TableField(value = "modify_time", fill = FieldFill.INSERT_UPDATE)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date modifyTime;
/** 备注 */
private String remark;
/** 微信用户id */
private String openid;
}
package vion.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
......@@ -12,12 +13,26 @@ import java.util.Date;
@TableName(value="tbl_user_info")
public class User {
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
private Long id;
private String userid;
private String username;
private String password;
private String phone;
private Date createTime;//创建时间
private Long deptId;
@TableField(value = "create_time", fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
@TableField(value = "modify_time", fill = FieldFill.INSERT_UPDATE)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date modifyTime;
private String remark;
}
/** 是否是预工单处理人 0:不是 1:是 */
private Integer preWorkOrder;
/** 员工状态 2:试用期 3:正式 5:待离职 -1:无状态 */
private Integer employeeStatus;
@TableField(exist = false)
private String token;
}
\ No newline at end of file
......@@ -3,7 +3,6 @@ package vion.service;
import com.baomidou.mybatisplus.extension.service.IService;
import vion.model.Account;
public interface IAccountSerrvice extends IService<Account> {
public interface IAccountService extends IService<Account> {
Account saveAndReturn(Account account);
}
......@@ -3,5 +3,5 @@ package vion.service;
import com.baomidou.mybatisplus.extension.service.IService;
import vion.model.Address;
public interface IAddressSerrvice extends IService<Address> {
public interface IAddressService extends IService<Address> {
}
package vion.service;
import com.baomidou.mybatisplus.extension.service.IService;
import vion.model.Dept;
/**
* @author HlQ
* @date 2023/11/10
*/
public interface IDeptService extends IService<Dept> {
}
......@@ -3,5 +3,5 @@ package vion.service;
import com.baomidou.mybatisplus.extension.service.IService;
import vion.model.Dictionary;
public interface IDictionarySerrvice extends IService<Dictionary> {
public interface IDictionaryService extends IService<Dictionary> {
}
package vion.service;
import com.baomidou.mybatisplus.extension.service.IService;
import vion.model.Account;
import vion.model.DictionaryType;
public interface IDictionaryTypeSerrvice extends IService<DictionaryType> {
public interface IDictionaryTypeService extends IService<DictionaryType> {
}
......@@ -3,5 +3,5 @@ package vion.service;
import com.baomidou.mybatisplus.extension.service.IService;
import vion.model.FaultLog;
public interface IFaultLogSerrvice extends IService<FaultLog> {
public interface IFaultLogService extends IService<FaultLog> {
}
package vion.service;
import com.baomidou.mybatisplus.extension.service.IService;
import vion.model.File;
import vion.model.FileInfo;
public interface IFileSerrvice extends IService<File> {
public interface IFileService extends IService<FileInfo> {
}
package vion.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import vion.dto.InspectDTO;
import vion.model.Inspect;
public interface IInspectSerrvice extends IService<Inspect> {
public interface IInspectService extends IService<Inspect> {
Inspect saveAndReturn(Inspect inspect);
Page<Inspect> getInspectList(InspectDTO data);
}
package vion.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import vion.dto.ProductDTO;
import vion.model.Product;
import vion.vo.ProductVO;
public interface IProductSerrvice extends IService<Product> {
public interface IProductService extends IService<Product> {
Product saveAndReturn(Product product);
Page<ProductVO> getProductList(ProductDTO productDTO);
}
package vion.service;
import com.baomidou.mybatisplus.extension.service.IService;
import vion.model.ServiceOrder;
/**
* @author HlQ
* @date 2023/11/21
*/
public interface IServiceOrderService extends IService<ServiceOrder> {
String sendOrder(Long id);
}
package vion.service;
import com.baomidou.mybatisplus.extension.service.IService;
import vion.model.Store;
public interface IStoreSerrvice extends IService<Store> {
Store saveAndReturn(Store store);
}
package vion.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import vion.dto.StatusDTO;
import vion.dto.StoreDTO;
import vion.model.Store;
import vion.vo.StoreVO;
public interface IStoreService extends IService<Store> {
Page<StoreVO> getStoreList(StoreDTO data);
String updateStoreStage(StatusDTO statusDTO, String token);
}
package vion.service;
import com.baomidou.mybatisplus.extension.service.IService;
import vion.model.Task;
public interface ITaskSerrvice extends IService<Task> {
Task saveAndReturn(Task task);
}
package vion.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import vion.dto.TaskDTO;
import vion.model.Task;
import vion.vo.TaskVO;
public interface ITaskService extends IService<Task> {
Page<TaskVO> getTaskList(TaskDTO data);
TaskVO getTaskById(Long taskId);
Long circTask(TaskDTO data, String token);
}
package vion.service;
import com.baomidou.mybatisplus.extension.service.IService;
import vion.model.TaskTemp;
public interface ITaskTempSerrvice extends IService<TaskTemp> {
TaskTemp saveAndReturn(TaskTemp taskTemp);
}
package vion.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import vion.dto.TaskTempDTO;
import vion.model.TaskTemp;
import vion.vo.TaskTempVO;
public interface ITaskTempService extends IService<TaskTemp> {
Page<TaskTempVO> getTaskTempList(TaskTempDTO data);
TaskTempVO getTaskTempById(Long id);
String saveOrUpdTaskTemp(TaskTempDTO data);
}
package vion.service;
import cn.hutool.core.lang.tree.Tree;
import com.baomidou.mybatisplus.extension.service.IService;
import vion.model.User;
public interface IUserSerrvice extends IService<User> {
import java.util.List;
public interface IUserService extends IService<User> {
List<Tree<String>> getOrgTree(String deptId);
User saveAndReturn(User user);
}
......@@ -4,14 +4,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import vion.mapper.AccountMapper;
import vion.model.Account;
import vion.service.IAccountSerrvice;
import vion.service.IAccountService;
@Service
public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> implements IAccountSerrvice {
@Override
public Account saveAndReturn(Account account) {
this.saveOrUpdate(account);
return account;
}
}
public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> implements IAccountService {
}
\ No newline at end of file
......@@ -4,8 +4,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import vion.mapper.AddressMapper;
import vion.model.Address;
import vion.service.IAddressSerrvice;
import vion.service.IAddressService;
@Service
public class AddressServiceImpl extends ServiceImpl<AddressMapper, Address> implements IAddressSerrvice {
public class AddressServiceImpl extends ServiceImpl<AddressMapper, Address> implements IAddressService {
}
package vion.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import vion.mapper.DeptMapper;
import vion.model.Dept;
import vion.service.IDeptService;
/**
* @author HlQ
* @date 2023/11/10
*/
@Service
public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements IDeptService {
}
......@@ -4,8 +4,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import vion.mapper.DictionaryMapper;
import vion.model.Dictionary;
import vion.service.IDictionarySerrvice;
import vion.service.IDictionaryService;
@Service
public class DictionaryServiceImpl extends ServiceImpl<DictionaryMapper, Dictionary> implements IDictionarySerrvice {
public class DictionaryServiceImpl extends ServiceImpl<DictionaryMapper, Dictionary> implements IDictionaryService {
}
......@@ -4,8 +4,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import vion.mapper.DictionaryTypeMapper;
import vion.model.DictionaryType;
import vion.service.IDictionaryTypeSerrvice;
import vion.service.IDictionaryTypeService;
@Service
public class DictionaryTypeServiceImpl extends ServiceImpl<DictionaryTypeMapper, DictionaryType> implements IDictionaryTypeSerrvice {
public class DictionaryTypeServiceImpl extends ServiceImpl<DictionaryTypeMapper, DictionaryType> implements IDictionaryTypeService {
}
......@@ -4,8 +4,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import vion.mapper.FaultLogMapper;
import vion.model.FaultLog;
import vion.service.IFaultLogSerrvice;
import vion.service.IFaultLogService;
@Service
public class FaultLogServiceImpl extends ServiceImpl<FaultLogMapper, FaultLog> implements IFaultLogSerrvice {
public class FaultLogServiceImpl extends ServiceImpl<FaultLogMapper, FaultLog> implements IFaultLogService {
}
......@@ -3,9 +3,9 @@ package vion.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import vion.mapper.FileMapper;
import vion.model.File;
import vion.service.IFileSerrvice;
import vion.model.FileInfo;
import vion.service.IFileService;
@Service
public class FileServiceImpl extends ServiceImpl<FileMapper, File> implements IFileSerrvice {
public class FileServiceImpl extends ServiceImpl<FileMapper, FileInfo> implements IFileService {
}
package vion.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import vion.dto.InspectDTO;
import vion.mapper.InspectMapper;
import vion.model.Account;
import vion.model.Inspect;
import vion.service.IInspectSerrvice;
import vion.model.Store;
import vion.service.IAccountService;
import vion.service.IInspectService;
import vion.service.IStoreService;
import java.util.List;
@Service
public class InspectServiceImpl extends ServiceImpl<InspectMapper, Inspect> implements IInspectSerrvice {
@RequiredArgsConstructor
public class InspectServiceImpl extends ServiceImpl<InspectMapper, Inspect> implements IInspectService {
private final IStoreService storeService;
private final IAccountService accountService;
private final Converter converter;
@Override
public Inspect saveAndReturn(Inspect inspect) {
this.saveOrUpdate(inspect);
return inspect;
public Page<Inspect> getInspectList(InspectDTO data) {
Page<Inspect> inspectList = this.lambdaQuery(converter.convert(data, new Inspect()))
.between(data.getStartdate() != null && data.getEnddate() != null, Inspect::getInspectTime, data.getStartdate(), data.getEnddate())
.page(Page.of(data.getPageNum(), data.getPageSize()));
List<Store> storeList = storeService.list();
List<Account> accountList = accountService.list();
inspectList.getRecords().forEach(item -> {
item.setAccountName(accountList.stream().filter(v -> v.getId().equals(item.getAccountId())).map(Account::getName).findFirst().orElse("--"));
item.setStoreName(storeList.stream().filter(v -> v.getId().equals(item.getStoreId())).map(Store::getName).findFirst().orElse("--"));
});
return inspectList;
}
}
package vion.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import vion.dto.ProductDTO;
import vion.mapper.ProductMapper;
import vion.model.Product;
import vion.service.IProductSerrvice;
import vion.model.Store;
import vion.service.IProductService;
import vion.service.IStoreService;
import vion.vo.ProductVO;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements IProductSerrvice {
@RequiredArgsConstructor
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements IProductService {
private final IStoreService storeService;
private final Converter converter;
@Override
public Product saveAndReturn(Product product) {
this.saveOrUpdate(product);
return product;
public Page<ProductVO> getProductList(ProductDTO productDTO) {
Page<Product> productList = this.page(Page.of(productDTO.getPageNum(), productDTO.getPageSize()), Wrappers.<Product>lambdaQuery()
.eq(productDTO.getStoreId() != null, Product::getStoreId, productDTO.getStoreId())
.eq(productDTO.getAccountId() != null, Product::getAccountId, productDTO.getAccountId())
.like(productDTO.getName() != null, Product::getName, productDTO.getName())
.eq(productDTO.getBrand() != null, Product::getBrand, productDTO.getBrand())
.eq(productDTO.getFunctionary() != null, Product::getFunctionary, productDTO.getFunctionary()));
List<Store> storeList = storeService.list();
List<ProductVO> productVOList = new ArrayList<>();
for (Product pro : productList.getRecords()) {
ProductVO productVO = converter.convert(pro, ProductVO.class);
productVO.setStoreName(storeList.stream().filter(store -> store.getId().equals(pro.getStoreId())).collect(Collectors.toList()).get(0).getName());
productVOList.add(productVO);
}
return Page.<ProductVO>of(productDTO.getPageNum(), productDTO.getPageSize(), productList.getTotal()).setRecords(productVOList);
}
}
package vion.service.impl;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.lang.Opt;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
import org.springframework.stereotype.Service;
import vion.ding.WechatMod;
import vion.mapper.ServiceOrderMapper;
import vion.model.ServiceOrder;
import vion.model.Task;
import vion.service.IServiceOrderService;
import vion.service.ITaskService;
import vion.service.ITaskTempService;
import java.util.List;
/**
* @author HlQ
* @date 2023/11/21
*/
@Service
@RequiredArgsConstructor
public class ServiceOrderServiceImpl extends ServiceImpl<ServiceOrderMapper, ServiceOrder> implements IServiceOrderService {
private final ITaskService taskService;
private final ITaskTempService taskTempService;
private final WechatMod wechatMod;
@Override
public String sendOrder(Long id) {
ServiceOrder order = this.getById(id);
Task task = taskService.getById(order.getTaskId());
return Opt.ofNullable(task.getTaskTempId())
.map(tempId -> taskTempService.getById(tempId).getOpenid())
.map(openid -> {
List<WxMpTemplateData> wxMpTemplateDataList = ListUtil.of(
new WxMpTemplateData("character_string5", task.getUuid()),
new WxMpTemplateData("thing1", order.getSubmitter() + "-" + order.getSubmitPhone()));
return wechatMod.sendMsg("NN6N58EOr0BE-D0f2vFipqUek4qtVXp08EJWjJora-M", openid, wxMpTemplateDataList, "https://yunwei.vionyun.com:8443/wap/service-bill?unid=" + order.getUnid());
})
.orElse("微信公众号消息推送失败,请检查工单是否绑定微信用户或联系管理员!");
}
}
package vion.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.lang.Opt;
import cn.hutool.crypto.SecureUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import vion.Global;
import vion.dto.StatusDTO;
import vion.dto.StoreDTO;
import vion.mapper.StoreMapper;
import vion.model.Account;
import vion.model.FileInfo;
import vion.model.Store;
import vion.service.IStoreSerrvice;
import vion.service.IAccountService;
import vion.service.IFileService;
import vion.service.IStoreService;
import vion.vo.StoreVO;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class StoreServiceImpl extends ServiceImpl<StoreMapper, Store> implements IStoreSerrvice {
@RequiredArgsConstructor
public class StoreServiceImpl extends ServiceImpl<StoreMapper, Store> implements IStoreService {
private final IAccountService accountService;
private final IFileService fileService;
private final Converter converter;
@Value("${fileUrl:}")
private String fileUrl;
@Override
public Page<StoreVO> getStoreList(StoreDTO data) {
Page<Store> storeList = this.lambdaQuery(converter.convert(data, new Store()))
.between(data.getStartdate() != null && data.getEnddate() != null, Store::getOrderdate, data.getStartdate(), data.getEnddate())
.page(Page.of(data.getPageNum(), data.getPageSize()));
// todo 缓存
List<Account> accountList = accountService.list();
List<FileInfo> fileInfoList = fileService.lambdaQuery().eq(FileInfo::getSourceType, 1).list();
Map<Long, Long> store2CntMap = fileInfoList.stream().collect(Collectors.groupingBy(FileInfo::getStoreId, Collectors.counting()));
List<StoreVO> storeVOList = new ArrayList<>();
storeList.getRecords().forEach(item -> {
StoreVO storeVO = converter.convert(item, new StoreVO());
storeVO.setAccountName(accountList.stream().filter(v -> v.getId().equals(item.getAccountId())).map(Account::getName).findFirst().orElse("--"));
storeVO.setFileNum(store2CntMap.getOrDefault(item.getId(), 0L));
storeVOList.add(storeVO);
});
return Page.<StoreVO>of(data.getPageNum(), data.getPageSize(), storeList.getTotal()).setRecords(storeVOList);
}
@Override
public Store saveAndReturn(Store store) {
this.saveOrUpdate(store);
return store;
public String updateStoreStage(StatusDTO statusDTO, String token) {
this.update(Wrappers.<Store>lambdaUpdate()
.set(Store::getProjectStage, statusDTO.getProjectStage())
.eq(Store::getId, statusDTO.getSourceId()));
Opt.ofNullable(statusDTO.getFiles()).ifPresent(tmpFiles -> {
for (MultipartFile infile : tmpFiles) {
//上传url地址
String orgName = infile.getOriginalFilename();
String fileName = orgName.substring(0, orgName.lastIndexOf("."));
String fileExt = orgName.substring(orgName.lastIndexOf("."));
String filename = fileName + "_" + DateUtil.format(new Date(), "yyyyMMdd_HHmmss") + fileExt;
String path = fileUrl + FileUtil.FILE_SEPARATOR + statusDTO.getStoreId() + FileUtil.FILE_SEPARATOR + statusDTO.getSourceId() + FileUtil.FILE_SEPARATOR + filename;
File file = FileUtil.touch(path);
try {
infile.transferTo(file);
} catch (IOException e) {
log.error("保存文件出错", e);
}
FileInfo tempFileInfo = new FileInfo();
tempFileInfo.setStoreId(statusDTO.getStoreId());
tempFileInfo.setSourceId(statusDTO.getSourceId());
tempFileInfo.setSourceType(statusDTO.getSourceType());
tempFileInfo.setName(filename);
tempFileInfo.setUrl(path);
tempFileInfo.setType(FileUtil.extName(file));
tempFileInfo.setSha256(SecureUtil.sha256(file).toUpperCase());
tempFileInfo.setUploader(Global.USERNAME_MAP.get(token).getUsername());
fileService.save(tempFileInfo);
}
});
return "更新成功";
}
}
package vion.service.impl;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.lang.Opt;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import vion.ding.DingMod;
import vion.ding.WechatMod;
import vion.dto.TaskTempDTO;
import vion.mapper.TaskTempMapper;
import vion.model.FileInfo;
import vion.model.TaskTemp;
import vion.service.ITaskTempSerrvice;
import vion.model.User;
import vion.service.IFileService;
import vion.service.ITaskTempService;
import vion.service.IUserService;
import vion.vo.TaskTempVO;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class TaskTempServiceImpl extends ServiceImpl<TaskTempMapper, TaskTemp> implements ITaskTempSerrvice {
@RequiredArgsConstructor
public class TaskTempServiceImpl extends ServiceImpl<TaskTempMapper, TaskTemp> implements ITaskTempService {
private final IFileService fileService;
private final IUserService userService;
private final DingMod dingMod;
private final WechatMod wechatMod;
private final Converter converter;
@Value("${fileUrl:}")
private String fileUrl;
@Override
public Page<TaskTempVO> getTaskTempList(TaskTempDTO data) {
Page<TaskTemp> taskTempPage = this
.lambdaQuery(converter.convert(data, new TaskTemp()))
.between(data.getStartdate() != null && data.getEnddate() != null, TaskTemp::getRepairTime, data.getStartdate(), data.getEnddate())
.page(Page.of(data.getPageNum(), data.getPageSize()));
List<TaskTempVO> taskTempVOList = converter.convert(taskTempPage.getRecords(), TaskTempVO.class);
return Page.<TaskTempVO>of(taskTempPage.getCurrent(), taskTempPage.getSize(), taskTempPage.getTotal()).setRecords(taskTempVOList);
}
@Override
public TaskTempVO getTaskTempById(Long id) {
TaskTemp taskTemp = this.getById(id);
List<FileInfo> fileInfos = Opt.ofNullable(taskTemp)
.map(tmp -> fileService.list(Wrappers.<FileInfo>lambdaUpdate()
.eq(FileInfo::getSourceId, tmp.getId())
.eq(FileInfo::getStoreId, 0L)))
.orElse(ListUtil.empty());
TaskTempVO taskTempVO = converter.convert(taskTemp, TaskTempVO.class);
taskTempVO.setFileList(fileInfos);
return taskTempVO;
}
@Override
public TaskTemp saveAndReturn(TaskTemp taskTemp) {
this.saveOrUpdate(taskTemp);
return taskTemp;
public String saveOrUpdTaskTemp(TaskTempDTO data) {
TaskTemp taskTemp = converter.convert(data, TaskTemp.class);
this.save(taskTemp);
Opt.ofNullable(data.getFiles())
.ifPresent(fileList ->
Arrays.stream(fileList).forEach(infile -> {
//上传url地址
String orgName = infile.getOriginalFilename();
String fileName = orgName.substring(0, orgName.lastIndexOf("."));
String fileExt = orgName.substring(orgName.lastIndexOf("."));
String filename = fileName + "_" + DateUtil.format(new Date(), "yyyyMMdd_HHmmss") + fileExt;
String path = fileUrl + FileUtil.FILE_SEPARATOR + 0 + FileUtil.FILE_SEPARATOR + taskTemp.getId() + FileUtil.FILE_SEPARATOR + filename;
File file = FileUtil.touch(path);
try {
infile.transferTo(file);
} catch (IOException e) {
log.error("保存文件出错", e);
}
FileInfo fileInfo = new FileInfo();
fileInfo.setStoreId(0L);
fileInfo.setSourceId(taskTemp.getId());
fileInfo.setSourceType(2);
fileInfo.setName(filename);
fileInfo.setUrl(path);
fileInfo.setType(FileUtil.extName(file));
fileInfo.setSha256(SecureUtil.sha256(file).toUpperCase());
fileInfo.setUploader(data.getRepairPeople());
fileService.save(fileInfo);
}));
// todo 异步发送钉钉消息通知
List<User> userList = userService.lambdaQuery().eq(User::getPreWorkOrder, 1).list();
String userids = userList.stream().map(User::getUserid).collect(Collectors.joining(","));
dingMod.sendMessage(buildMsg(userids, taskTemp));
return wechatMod.genCodeUrl(taskTemp.getId());
}
JSONObject buildMsg(String userid, TaskTemp taskTemp) {
JSONObject jsonObj = new JSONObject();
jsonObj.set("agent_id", 2358374016L);
jsonObj.set("userid_list", userid);
JSONObject msg = new JSONObject();
JSONObject content = new JSONObject();
content.set("title", "客户提交工单,请及时处理哦~_~");
content.set("markdown", "门店信息: " + taskTemp.getStoreName() +
" \n 客户姓名:" + taskTemp.getRepairPeople() +
" \n 联系方式:" + taskTemp.getRepairPhone() +
" \n 故障描述:" + taskTemp.getFaultDescription() +
" \n 发送时间:" + DateUtil.now());
content.set("btn_orientation", "1");
JSONArray jsonArray = new JSONArray();
jsonArray.add(new JSONObject().set("title", "查看详情").set("action_url", "https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingkrzwks0jpi2di3uo&response_type=code&scope=snsapi_auth&state=STATE&redirect_uri=https%3A%2F%2Fyunwei.vionyun.com%3A8443%2Fyunwei%2Fapi%2Fding%2Fcallback%2Finside%3FtaskTempId%3D" + taskTemp.getId()));
content.set("btn_json_list", jsonArray);
msg.set("msgtype", "action_card");
msg.set("action_card", content);
jsonObj.set("msg", msg);
return jsonObj;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!