Commit ee3b94fe by 李苗

[add]工单项目接口调整

1 parent f44b4033
......@@ -11,4 +11,9 @@
</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
......@@ -39,6 +39,7 @@ public class Application implements CommandLineRunner {
logger.info("启动");
//定时获取钉钉用户列表
userController.getDingUserList();
//USERNAME_MAP
logger.info("启动完成");
} catch (Exception e) {
......
package vion;
import vion.model.User;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class Global {
public static final String BASE_URL = "/api";
public static final String ACCOUNT_URL = "/api/account";
public static final String STORE_URL = "/api/store";
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.controller;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
......@@ -9,9 +10,11 @@ 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 java.util.Comparator;
import java.util.Date;
import java.util.List;
......@@ -29,9 +32,12 @@ public class AccountController {
@RequestParam(name = "pageSize")Integer pageSize){
//pageNum当前页,pageSize每页条数
PageHelper.startPage(pageNum,pageSize);
Page page= PageHelper.startPage(pageNum,pageSize);
List<Account> accountList=accountSerrvice.list();
PageInfo pageInfo=new PageInfo(accountList,10);
accountList.sort(Comparator.comparing(Account::getId));
PageInfo pageInfo=new PageInfo<>(page);
pageInfo.setList(accountList);
if (accountList != null) {
......@@ -61,13 +67,12 @@ public class AccountController {
try {
if(data.getId()==null){
accountSerrvice.save(data);
return ResultUtil.success();
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);
......
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 lombok.extern.slf4j.Slf4j;
......@@ -9,9 +11,12 @@ import vion.Global;
import vion.enums.ResultEnum;
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;
@RestController
......@@ -27,11 +32,19 @@ public class DictionaryController {
@GetMapping("/dictionarys")
@ResponseBody
public Object getDictionaryList(@RequestParam(name = "pageNum")Integer pageNum,
@RequestParam(name = "pageSize")Integer pageSize){
@RequestParam(name = "pageSize")Integer pageSize,
@RequestParam(name = "type",required=false)String type){
//pageNum当前页,pageSize每页条数
PageHelper.startPage(pageNum,pageSize);
List<Dictionary> dictionaryList=dictionarySerrvice.list();
PageInfo pageInfo=new PageInfo(dictionaryList,10);
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);
......
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 lombok.extern.slf4j.Slf4j;
......@@ -11,13 +13,18 @@ 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.utils.ResultUtil;
import vion.vo.StoreVO;
import javax.servlet.http.HttpServletResponse;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -36,16 +43,22 @@ public class FileController {
@GetMapping("/files")
@ResponseBody
public Object getAccountList(@RequestParam(name = "store_id")Integer store_id,
@RequestParam(name = "source_id")Integer source_id,
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每页条数
PageHelper.startPage(pageNum,pageSize);
List<File> fileList=fileSerrvice.list(Wrappers.<File>lambdaQuery()
.eq(File::getSourceId,source_id)
.eq(File::getStoreId,store_id));
PageInfo pageInfo=new PageInfo(fileList,10);
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);
......@@ -54,6 +67,50 @@ public class FileController {
}
}
@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);
}
return resultMap;
}
@PostMapping("/upLoadFile")
public Map<String, Object> uploadFile(@RequestParam(name="file") MultipartFile file){
Map<String, Object> resultMap = new HashMap<String, Object>();
......@@ -64,10 +121,12 @@ public class FileController {
file.transferTo(fileinfo);
resultMap.put("msg_code", "200");
resultMap.put("msg_code", 200);
resultMap.put("fileUrl",path);
} catch (IOException e) {
e.printStackTrace();
resultMap.put("msg_code", "500");
resultMap.put("msg_code", 500);
resultMap.put("message",e.getMessage());
}
return resultMap;
}
......@@ -76,7 +135,6 @@ public class FileController {
public void downLoadFile(@RequestParam(name="fileurl")String fileurl,
@RequestParam(name="filename")String filename,
HttpServletResponse response){
Map<String, Object> resultMap = new HashMap<String, Object>();
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition","attachment;filename="+filename);
java.io.File file=new java.io.File(fileurl);
......@@ -97,4 +155,16 @@ public class FileController {
e.printStackTrace();
}
}
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;
}
}
......@@ -2,17 +2,21 @@ 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 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.model.Inspect;
import vion.model.Store;
import vion.service.IInspectSerrvice;
import vion.utils.ResultUtil;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
......@@ -26,27 +30,32 @@ public class InspectController {
@GetMapping("/inspects")
@ResponseBody
public Object getProductList(@RequestParam(name = "store_id")Integer store_id,
public Object getProductList(@RequestParam(name = "storeId",required=false)Integer store_id,
@RequestParam(name = "status",required=false)Integer status,
@RequestParam(name = "startdate",required=false) Date startdate,
@RequestParam(name = "enddate",required=false)Date enddate,
@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每页条数
PageHelper.startPage(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.ge("inspect_date",startdate);
if(enddate!=null)
wrapper.le("inspect_date",enddate);
wrapper.between("inspect_date",startdate,enddate);
List<Inspect> inspectList=inspectSerrvice.list(wrapper);
PageInfo pageInfo=new PageInfo(inspectList,10);
inspectList.sort(Comparator.comparing(Inspect::getId));
PageInfo pageInfo=new PageInfo<>(page);
pageInfo.setList(inspectList);
if (inspectList != null) {
return ResultUtil.success(pageInfo);
} else {
......@@ -82,7 +91,8 @@ public class InspectController {
}
}catch (Exception e) {
return ResultUtil.error(ResultEnum.SELECT_ERROR);
// return ResultUtil.error(ResultEnum.SELECT_ERROR);
return e.getMessage().toString();
}
}
......
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 lombok.extern.slf4j.Slf4j;
......@@ -9,11 +10,17 @@ import org.springframework.web.bind.annotation.*;
import vion.Global;
import vion.enums.ResultEnum;
import vion.model.Product;
import vion.model.Store;
import vion.service.IProductSerrvice;
import vion.service.IStoreSerrvice;
import vion.utils.ResultUtil;
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)
......@@ -22,11 +29,13 @@ public class ProductController {
@Autowired
private IProductSerrvice productSerrvice;
@Autowired
private IStoreSerrvice storeSerrvice;
@GetMapping("/products")
@ResponseBody
public Object getProductList(@RequestParam(name = "account_id")Integer account_id,
@RequestParam(name = "store_id")Integer store_id,
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,
......@@ -34,10 +43,13 @@ public class ProductController {
@RequestParam(name = "pageSize")Integer pageSize){
//pageNum当前页,pageSize每页条数
PageHelper.startPage(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);
......@@ -46,9 +58,37 @@ public class ProductController {
if(functionary!=null)
wrapper.eq("functionary",functionary);
List<Product> productList=productSerrvice.list(wrapper);
PageInfo pageInfo=new PageInfo(productList,10);
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 {
......@@ -58,7 +98,7 @@ public class ProductController {
@GetMapping("/product")
@ResponseBody
public Object getProductByID(@RequestParam(name = "project_id")Integer project_id){
public Object getProductByID(@RequestParam(name = "projectId")Integer project_id){
Product product=productSerrvice.getById(project_id);
......@@ -84,7 +124,8 @@ public class ProductController {
}
}catch (Exception e) {
return ResultUtil.error(ResultEnum.SELECT_ERROR);
//return ResultUtil.error(ResultEnum.SELECT_ERROR);
return e.getMessage().toString();
}
}
}
......@@ -3,10 +3,12 @@ package vion.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
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;
......@@ -16,10 +18,10 @@ import vion.service.IFileSerrvice;
import vion.service.IStoreSerrvice;
import vion.utils.ResultUtil;
import vion.vo.StatusVO;
import vion.vo.StoreListVO;
import vion.vo.StoreVO;
import java.util.Date;
import java.util.List;
import java.util.*;
@RestController
@RequestMapping(Global.BASE_URL)
......@@ -35,22 +37,27 @@ public class StoreController {
@GetMapping("/stores")
@ResponseBody
public Object getStoreList(@RequestParam(name = "account_id")Integer account_id,
@RequestParam(name = "store_id")Integer store_id,
public Object getStoreList(@RequestParam(name = "accountId",required=false)Integer account_id,
@RequestParam(name = "storeId",required=false)Integer store_id,
@RequestParam(name = "storenum",required=false)String storenum,
@RequestParam(name = "project_state",required=false)Integer project_state,
@RequestParam(name = "projectState",required=false)Integer project_state,
@RequestParam(name = "salesperson",required=false)String salesperson,
@RequestParam(name = "implement_type",required=false)Integer implement_type,
@RequestParam(name = "startdate",required=false) Date startdate,
@RequestParam(name = "enddate",required=false) Date enddate,
@RequestParam(name = "implementType",required=false)Integer implement_type,
@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每页条数
PageHelper.startPage(pageNum,pageSize);
Page page= PageHelper.startPage(pageNum,pageSize);
QueryWrapper<Store> wrapper=new QueryWrapper<>();
wrapper.eq("store_id",store_id);
if(store_id!=null){
wrapper.eq("id",store_id);
}
if(account_id!=null)
wrapper.eq("account_id",account_id);
if(storenum!=null)
wrapper.eq("storenum",storenum);
......@@ -61,13 +68,14 @@ public class StoreController {
if(implement_type!=null)
wrapper.eq("implement_type",implement_type);
if(startdate!=null)
wrapper.ge("orderdate",startdate);
if(enddate!=null)
wrapper.le("orderdate",enddate);
wrapper.between("orderdate",startdate,enddate);
List<Store> storeList=storeSerrvice.list(wrapper);
PageInfo pageInfo=new PageInfo(storeList,10);
storeList.sort(Comparator.comparing(Store::getId));
PageInfo pageInfo=new PageInfo<>(page);
pageInfo.setList(storeList);
if (pageInfo != null) {
return ResultUtil.success(pageInfo);
......@@ -80,7 +88,7 @@ public class StoreController {
@ResponseBody
public Object getStoreByID(@RequestParam(name = "id")Integer id){
StoreVO storeVo=new StoreVO();//storeDao.getStoreByID(store_id);
StoreVO storeVo=new StoreVO();
Store store=storeSerrvice.getById(id);
storeVo.setId(store.getId());
......@@ -90,26 +98,29 @@ public class StoreController {
storeVo.setAmount(store.getAmount());
storeVo.setOrderdate(store.getOrderdate());
storeVo.setSalesperson(store.getSalesperson());
storeVo.setWarranty_period(store.getWarrantyPeriod());
storeVo.setCustomer_name(store.getCustomerName());
storeVo.setProject_stage(store.getProjectStage());
storeVo.setProject_state(store.getProjectState());
storeVo.setWarrantyPeriod(store.getWarrantyPeriod());
storeVo.setCustomerName(store.getCustomerName());
storeVo.setProjectStage(store.getProjectStage());
storeVo.setProjectState(store.getProjectState());
storeVo.setContacts(store.getContacts());
storeVo.setRemark(store.getRemark());
storeVo.setAccountId(store.getAccountId());
storeVo.setContractCode(store.getContractCode());
storeVo.setImplementType(store.getImplementType());
//获取地址信息
Address address=addressSerrvice.getOne(Wrappers.<Address>lambdaQuery()
.eq(Address::getStoreId,id));
if(address!=null){
storeVo.setConsignee_name(address.getConsigneeName());
storeVo.setConsignee_phone(address.getConsigneePhone());
storeVo.setConsignee_address(address.getConsigneeAddress());
storeVo.setContract_name(address.getContractName());
storeVo.setContract_phone(address.getContractPhone());
storeVo.setContract_address(address.getContractAddress());
storeVo.setInvoice_name(address.getInvoiceName());
storeVo.setInvoice_phone(address.getInvoicePhone());
storeVo.setInvoice_address(address.getInvoiceAddress());
storeVo.setInvoice_info(address.getInvoiceInfo());
storeVo.setConsigneeName(address.getConsigneeName());
storeVo.setConsigneePhone(address.getConsigneePhone());
storeVo.setConsigneeAddress(address.getConsigneeAddress());
storeVo.setContractName(address.getContractName());
storeVo.setContractPhone(address.getContractPhone());
storeVo.setContractAddress(address.getContractAddress());
storeVo.setInvoiceName(address.getInvoiceName());
storeVo.setInvoicePhone(address.getInvoicePhone());
storeVo.setInvoiceAddress(address.getInvoiceAddress());
storeVo.setInvoiceInfo(address.getInvoiceInfo());
}
if (storeVo != null) {
......@@ -118,10 +129,38 @@ public class StoreController {
return ResultUtil.error(ResultEnum.SELECT_ERROR);
}
}
@GetMapping("/storeList")
@ResponseBody
public Object getStoreList(@RequestParam(name = "accountId",required=false)Integer account_id){
QueryWrapper<Store> wrapper=new QueryWrapper<>();
if(account_id!=null)
wrapper.eq("account_id",account_id);
List<Store> storeList=storeSerrvice.list(wrapper);
List<StoreListVO> storeListVOS=new ArrayList<>();
for (Store store : storeList){
StoreListVO storeListVO=new StoreListVO();
storeListVO.setId(store.getId());
storeListVO.setName(store.getName());
storeListVOS.add(storeListVO);
}
storeListVOS.sort(Comparator.comparing(StoreListVO::getId));
if (storeListVOS != null) {
return ResultUtil.success(storeListVOS);
} else {
return ResultUtil.error(ResultEnum.SELECT_ERROR);
}
}
@PostMapping("/stores")
@ResponseBody
public Object saveOrUpdate(@RequestBody StoreVO storeVo) {
public Object saveOrUpdate(@RequestBody StoreVO storeVo,@RequestAttribute String userid) {
User user=Global.USERNAME_MAP.get(userid);
Store store=new Store();
store.setId(storeVo.getId());
......@@ -131,34 +170,48 @@ public class StoreController {
store.setAmount(storeVo.getAmount());
store.setOrderdate(storeVo.getOrderdate());
store.setSalesperson(storeVo.getSalesperson());
store.setWarrantyPeriod(storeVo.getWarranty_period());
store.setCustomerName(storeVo.getCustomer_name());
store.setProjectStage(storeVo.getProject_stage());
store.setProjectState(storeVo.getProject_state());
store.setWarrantyPeriod(storeVo.getWarrantyPeriod());
store.setCustomerName(storeVo.getCustomerName());
store.setProjectStage(storeVo.getProjectStage());
store.setProjectState(storeVo.getProjectState());
store.setContacts(storeVo.getContacts());
store.setContractCode(storeVo.getContractCode());
store.setImplementType(storeVo.getImplementType());
store.setRemark(storeVo.getRemark());
Address address=addressSerrvice.getOne(Wrappers.<Address>lambdaQuery()
.eq(Address::getStoreId,storeVo.getId()));
address.setConsigneeName(storeVo.getConsignee_name());
address.setConsigneePhone(storeVo.getConsignee_phone());
address.setConsigneeAddress(storeVo.getConsignee_address());
address.setContractName(storeVo.getContract_name());
address.setContractPhone(storeVo.getContract_phone());
address.setContractAddress(storeVo.getContract_address());
address.setInvoiceName(storeVo.getInvoice_name());
address.setInvoicePhone(storeVo.getInvoice_phone());
address.setInvoiceAddress(storeVo.getInvoice_address());
address.setInvoiceInfo(storeVo.getInvoice_info());
store.setAccountId(storeVo.getAccountId());
if(storeVo.getId()!=null) {
store.setModifyUser(user.getId());
}else{
store.setCreateUser(user.getId());
}
try {
storeSerrvice.saveOrUpdate(store);
Store store1= storeSerrvice.saveAndReturn(store);
Address address=addressSerrvice.getOne(Wrappers.<Address>lambdaQuery()
.eq(Address::getStoreId,store1.getId()));
if(address==null){
address=new Address();
address.setStoreId(store1.getId());
}
address.setConsigneeName(storeVo.getConsigneeName());
address.setConsigneePhone(storeVo.getConsigneePhone());
address.setConsigneeAddress(storeVo.getConsigneeAddress());
address.setContractName(storeVo.getContractName());
address.setContractPhone(storeVo.getContractPhone());
address.setContractAddress(storeVo.getContractAddress());
address.setInvoiceName(storeVo.getInvoiceName());
address.setInvoicePhone(storeVo.getInvoicePhone());
address.setInvoiceAddress(storeVo.getInvoiceAddress());
address.setInvoiceInfo(storeVo.getInvoiceInfo());
addressSerrvice.saveOrUpdate(address);
return ResultUtil.success();
}catch (Exception e) {
return ResultUtil.error(ResultEnum.SELECT_ERROR);
// return ResultUtil.error(ResultEnum.SELECT_ERROR);
return e.getMessage().toString();
}
}
......@@ -170,23 +223,24 @@ public class StoreController {
//更新项目阶段
//storeDao.updateStoreStage(statusVo.getSource_id(),statusVo.getProject_stage());
UpdateWrapper updateWrapper=new UpdateWrapper();
updateWrapper.eq("id",statusVo.getSource_id());
updateWrapper.set("project_stage",statusVo.getProject_stage());
updateWrapper.eq("id",statusVo.getSourceId());
updateWrapper.set("project_stage",statusVo.getProjectStage());
storeSerrvice.update(updateWrapper);
//添加文件附件
File file=new File();
file.setStoreId(statusVo.getStore_id());
file.setSourceId(statusVo.getSource_id());
file.setSourceType(statusVo.getSource_type());//1项目、2工单预处理,3工单操作,4巡检
file.setStoreId(statusVo.getStoreId());
file.setSourceId(statusVo.getSourceId());
file.setSourceType(statusVo.getSourceType());//1项目、2工单预处理,3工单操作,4巡检
file.setName(statusVo.getName());
file.setUrl(statusVo.getUrl());
file.setType(statusVo.getFile_type());
file.setType(statusVo.getType());
fileSerrvice.save(file);
return ResultUtil.success();
}catch (Exception e) {
return ResultUtil.error(ResultEnum.SELECT_ERROR);
// return ResultUtil.error(ResultEnum.SELECT_ERROR);
return e.getMessage().toString();
}
}
}
......@@ -3,24 +3,28 @@ package vion.controller;
import cn.hutool.core.util.StrUtil;
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 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.model.*;
import vion.service.IFaultLogSerrvice;
import vion.service.IFileSerrvice;
import vion.service.ITaskSerrvice;
import vion.service.ITaskTempSerrvice;
import vion.service.*;
import vion.service.impl.UserServiceImpl;
import vion.utils.ResultUtil;
import vion.vo.FaultLogVO;
import vion.vo.ProductVO;
import vion.vo.TaskVO;
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)
......@@ -35,35 +39,76 @@ public class TaskController {
private IFileSerrvice fileSerrvice;
@Autowired
private IFaultLogSerrvice faultLogSerrvice;
@Autowired
private FileController fileController;
@Autowired
private IStoreSerrvice storeSerrvice;
@Autowired
private UserController userController;
@Autowired
private IUserSerrvice iUserSerrvice;
@GetMapping("/tasks")
@ResponseBody
public Object getStoreList(@RequestParam(name = "account_id")Integer account_id,
@RequestParam(name = "store_id")Integer store_id,
@RequestParam(name = "fault_type",required=false)Integer fault_type,
public Object gettaskList(@RequestParam(name = "accountId",required=false)Integer account_id,
@RequestParam(name = "storeId",required=false)Integer store_id,
@RequestParam(name = "faultType",required=false)Integer fault_type,
@RequestParam(name = "status",required=false)Integer status,
@RequestParam(name = "startdate",required=false) Date startdate,
@RequestParam(name = "enddate",required=false) Date enddate,
@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每页条数
PageHelper.startPage(pageNum,pageSize);
Page page= PageHelper.startPage(pageNum,pageSize);
QueryWrapper<Task> wrapper=new QueryWrapper<>();
if(store_id!=null){
wrapper.eq("store_id",store_id);
}
if(account_id!=null)
wrapper.eq("account_id",account_id);
if(fault_type!=null)
wrapper.eq("fault_type",fault_type);
if(status!=null)
wrapper.eq("status",status);
if(startdate!=null)
wrapper.ge("repair_date",startdate);
if(enddate!=null)
wrapper.le("repair_date",enddate);
wrapper.between("repair_date",startdate,enddate);
List<Task> taskList=taskSerrvice.list(wrapper);
PageInfo pageInfo=new PageInfo(taskList,10);
List<Store> storeList=storeSerrvice.list();
List<TaskVO> taskVOS=new ArrayList<>();
TaskVO taskVO;
for(Task task:taskList){
taskVO=new TaskVO();
taskVO.setStoreName(storeList.stream().filter(store -> store.getId().equals(task.getStoreId())).collect(Collectors.toList()).get(0).getName());
taskVO.setId(task.getId());
taskVO.setStoreId(task.getStoreId());
taskVO.setRepairDate(task.getRepairDate());
taskVO.setFaultType(task.getFaultType());
taskVO.setFaultDescription(task.getFaultDescription());
taskVO.setRepairPeople(task.getRepairPeople());
taskVO.setRepairPhone(task.getRepairPhone());
taskVO.setStatus(task.getStatus());
taskVO.setFaultReason(task.getFaultReason());
taskVO.setSolveDate(task.getSolveDate());
taskVO.setSolveType(task.getSolveType());
taskVO.setSolveDescription(task.getSolveDescription());
taskVO.setCreateUser(task.getCreateUser());
taskVO.setActiveUser(task.getActiveUser());
taskVO.setCreateTime(task.getCreateTime());
taskVO.setModifyTime(task.getModifyTime());
taskVO.setRemark(task.getRemark());
taskVO.setAccountId(task.getAccountId());
taskVOS.add(taskVO);
}
taskVOS.sort(Comparator.comparing(TaskVO::getId));
PageInfo pageInfo=new PageInfo<>(page);
pageInfo.setList(taskVOS);
if (pageInfo != null) {
return ResultUtil.success(pageInfo);
......@@ -74,12 +119,33 @@ public class TaskController {
@GetMapping("/task")
@ResponseBody
public Object getWorkByID(@RequestParam(name = "task_id")Integer task_id){
public Object getTaskByID(@RequestParam(name = "taskId")Integer task_id){
Task task=taskSerrvice.getById(task_id);
List<File> files=fileController.getFileList(task.getStoreId(),task.getId());
TaskVO taskVO=new TaskVO();
taskVO.setId(task.getId());
taskVO.setStoreId(task.getStoreId());
taskVO.setRepairDate(task.getRepairDate());
taskVO.setFaultType(task.getFaultType());
taskVO.setFaultDescription(task.getFaultDescription());
taskVO.setRepairPeople(task.getRepairPeople());
taskVO.setRepairPhone(task.getRepairPhone());
taskVO.setStatus(task.getStatus());
taskVO.setFaultReason(task.getFaultReason());
taskVO.setSolveDate(task.getSolveDate());
taskVO.setSolveType(task.getSolveType());
taskVO.setSolveDescription(task.getSolveDescription());
taskVO.setCreateUser(task.getCreateUser());
taskVO.setActiveUser(task.getActiveUser());
taskVO.setCreateTime(task.getCreateTime());
taskVO.setModifyTime(task.getModifyTime());
taskVO.setRemark(task.getRemark());
taskVO.setAccountId(task.getAccountId());
taskVO.setFileList(files);
if (task != null) {
return ResultUtil.success(task);
if (taskVO != null) {
return ResultUtil.success(taskVO);
} else {
return ResultUtil.error(ResultEnum.SELECT_ERROR);
}
......@@ -87,95 +153,149 @@ public class TaskController {
@PostMapping("/tasks")
@ResponseBody
public Object saveOrUpdate(@RequestBody TaskVO data) {
public Object saveOrUpdate(@RequestBody TaskVO data,@RequestAttribute String userid) {
try {
User user=Global.USERNAME_MAP.get(userid);
Task task=new Task();
task.setAccountId(data.getAccount_id());
task.setStoreId(data.getStore_id());
task.setFaultType(data.getFault_type());
task.setFaultDescription(data.getFault_description());
task.setRepairDate(data.getRepair_date());
task.setRepairPeople(data.getRepair_people());
task.setRepairPhone(data.getRepair_phone());
task.setAccountId(data.getAccountId());
task.setStoreId(data.getStoreId());
task.setFaultType(data.getFaultType());
task.setFaultDescription(data.getFaultDescription());
task.setRepairDate(data.getRepairDate());
task.setRepairPeople(data.getRepairPeople());
task.setRepairPhone(data.getRepairPhone());
task.setStatus(data.getStatus());
task.setCreateUser(data.getCreate_user());
if(task.getId()==null){
task.setCreateUser(user.getId());
}
task.setActiveUser(data.getActiveUser());
if(data.getWorktemp_id()!=null){
if(data.getTasktempId()!=null){
//得到预处理工单
// TaskTemp taskTemp= taskTempDao.getTaskTempByID(data.getWorktemp_id());
TaskTemp taskTemp= taskTempSerrvice.getById(data.getWorktemp_id());
TaskTemp taskTemp= taskTempSerrvice.getById(data.getTasktempId());
//更新预处理工单状态
taskTemp.setStatus(2);//状态(1待确认、2已确认)
taskTemp.setModifyTime(new Date());
taskTemp.setOperator(data.getCurrentuser());
taskTemp.setStoreId(data.getStore_id());
taskTemp.setOperator(data.getActiveUser());
taskTemp.setStoreId(data.getStoreId());
taskTemp.setModifyTime(new Date());
//taskTempDao.updateTaskTemp(taskTemp);
taskTempSerrvice.saveOrUpdate(taskTemp);
//根据预处理工单更新附件的门店ID
fileSerrvice.lambdaUpdate()
.setSql("store_id="+data.getStore_id())
.setSql("store_id="+data.getStoreId())
.eq(File::getSourceId,data.getId())
.update();
//fileDao.updateFileStoreid(fileTemp);
}
if(data.getId()==null){
//添加新工单
// Task work= taskDao.addTask(task);
Task work=taskSerrvice.saveAndReturn(task);
if(data.getFileList()!=null){
//添加新工单的附件信息
if(work!=null && data.getFilename()!=null){
File file=new File();
if(work!=null){
File file;
for(File fileModel:data.getFileList()){
file=new File();
file.setId(fileModel.getId());
file.setStoreId(work.getStoreId());
file.setSourceId(work.getId());
file.setSourceType(3);//1项目、2工单预处理,3工单操作,4巡检
file.setName(data.getFilename());
file.setUrl(data.getFileurl());
file.setType(1);
fileSerrvice.save(file);
file.setName(fileModel.getName());
file.setUrl(fileModel.getUrl());
file.setType(fileModel.getType());
fileSerrvice.saveOrUpdate(file);
}
}
}
//添加工单处理日志
FaultLog faultLog=new FaultLog();
faultLog.setTaskId(work.getId());
faultLog.setStoreId(work.getStoreId());
faultLog.setOperator(user.getId());
faultLog.setContent("创建工单");
faultLog.setRemark("");
faultLogSerrvice.saveOrUpdate(faultLog);
//发送钉钉提醒
User activeUser= iUserSerrvice.getById(work.getActiveUser());
userController.sendMessage(activeUser.getUserid(),work.getId());
}
else{
task.setId(data.getId());
task.setSolveDate(data.getSolve_date());
task.setFaultReason(data.getFault_reason());
task.setSolveType(data.getSolve_type());
task.setSolveDescription(data.getSolve_description());
task.setCurrentuser(data.getCurrentuser());
task.setSolveDate(data.getSolveDate());
task.setFaultReason(data.getFaultReason());
task.setSolveType(data.getSolveType());
task.setSolveDescription(data.getSolveDescription());
task.setRemark(data.getRemark());
// taskDao.updateTask(task);
taskSerrvice.saveOrUpdate(task);
if(data.getFilename()!=null){
//添加文件附件
//根据状态判断是否要添加工单处理日志(//状态:0待确认1进行中2已完成3挂起)
if(data.getStatus()==1){
FaultLog faultLog=new FaultLog();
faultLog.setTaskId(data.getId());
faultLog.setStoreId(data.getStoreId());
faultLog.setOperator(user.getId());
faultLog.setContent("工单正在处理中");
faultLog.setRemark(data.getSolveDescription());
faultLogSerrvice.saveOrUpdate(faultLog);
}
if(data.getStatus()==2){
FaultLog faultLog=new FaultLog();
faultLog.setTaskId(data.getId());
faultLog.setStoreId(data.getStoreId());
faultLog.setOperator(user.getId());
faultLog.setContent("工单处理完成");
faultLog.setRemark(data.getSolveDescription());
faultLogSerrvice.saveOrUpdate(faultLog);
}
if(data.getStatus()==3){
FaultLog faultLog=new FaultLog();
faultLog.setTaskId(data.getId());
faultLog.setStoreId(data.getStoreId());
faultLog.setOperator(user.getId());
faultLog.setContent("工单挂起");
faultLog.setRemark(data.getSolveDescription());
faultLogSerrvice.saveOrUpdate(faultLog);
}
//判断是否要添加工单处理文件
if(data.getFileList()!=null){
//添加新工单的附件信息
for(File fileModel:data.getFileList()){
File file=new File();
file.setStoreId(data.getStore_id());
file.setId(fileModel.getId());
file.setStoreId(data.getStoreId());
file.setSourceId(data.getId());
file.setSourceType(3);//1项目、2工单预处理,3工单操作,4巡检
file.setName(data.getFilename());
file.setUrl(data.getFileurl());
file.setType(1);
fileSerrvice.save(file);
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();
}
}
@GetMapping("/faultLogs")
@ResponseBody
public Object getFaultLogByID(@RequestParam(name = "store_id")Integer store_id,
@RequestParam(name = "task_id")Integer task_id){
public Object getFaultLogByID(@RequestParam(name = "storeId")Integer store_id,
@RequestParam(name = "taskId")Integer task_id){
//FaultLog faultLog=taskDao.getFaultlogByStoreID(store_id,task_id);
List<FaultLog> faultLogs=faultLogSerrvice.list(Wrappers.<FaultLog>lambdaQuery()
.eq(FaultLog::getStoreId,store_id)
.eq(FaultLog::getTaskId,task_id));
......@@ -189,23 +309,23 @@ public class TaskController {
@PostMapping("/faultLogs")
@ResponseBody
public Object saveAddFaultLog(@RequestBody FaultLogVO data) {
public Object saveAddFaultLog(@RequestBody FaultLogVO data,@RequestAttribute String userid) {
try {
User user=Global.USERNAME_MAP.get(userid);
FaultLog faultLog=new FaultLog();
faultLog.setTaskId(data.getTask_id());
faultLog.setStoreId(data.getStore_id());
faultLog.setOperator(data.getOperator());
faultLog.setTaskId(data.getTaskId());
faultLog.setStoreId(data.getStoreId());
faultLog.setOperator(user.getId());
faultLog.setContent(data.getContent());
faultLog.setRemark(data.getRemark());
// taskDao.addFaultLog(faultLog);
faultLogSerrvice.saveOrUpdate(faultLog);
if(data.getFilename()!=null){
//添加文件附件
File file=new File();
file.setStoreId(data.getStore_id());
file.setSourceId(data.getTask_id());
file.setStoreId(data.getStoreId());
file.setSourceId(data.getTaskId());
file.setSourceType(3);//1项目、2工单预处理,3工单操作,4巡检
file.setName(data.getFilename());
file.setUrl(data.getFileurl());
......@@ -215,7 +335,8 @@ public class TaskController {
}
return ResultUtil.success();
}catch (Exception e) {
return ResultUtil.error(ResultEnum.SELECT_ERROR);
// return ResultUtil.error(ResultEnum.SELECT_ERROR);
return e.getMessage().toString();
}
}
......
......@@ -2,21 +2,25 @@ 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 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 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.vo.TaskTempVO;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
......@@ -29,34 +33,40 @@ public class TaskTempController {
private ITaskTempSerrvice taskTempSerrvice;
@Autowired
private IFileSerrvice fileSerrvice;
@Autowired
private FileController fileController;
@GetMapping("/taskTemps")
@ResponseBody
public Object getTaskTempList(@RequestParam(name = "store_name",required=false)String store_name,
@RequestParam(name = "store_id",required=false)Integer store_id,
@RequestParam(name = "startdate",required=false)Date startdate,
@RequestParam(name = "enddate",required=false)Date enddate,
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每页条数
PageHelper.startPage(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.eq("store_name",store_name);
wrapper.like("store_name",store_name);
if(status!=null)
wrapper.eq("status",status);
if(startdate!=null)
wrapper.ge("repair_date",startdate);
if(enddate!=null)
wrapper.le("repair_date",enddate);
wrapper.between("repair_date",startdate,enddate);
List<TaskTemp> taskTempList= taskTempSerrvice.list(wrapper);
PageInfo pageInfo=new PageInfo(taskTempList,10);
taskTempList.sort(Comparator.comparing(TaskTemp::getId));
PageInfo pageInfo=new PageInfo<>(page);
pageInfo.setList(taskTempList);
if (pageInfo != null) {
return ResultUtil.success(pageInfo);
......@@ -69,10 +79,22 @@ public class TaskTempController {
@ResponseBody
public Object getTaskTempByID(@RequestParam(name = "id")Integer id){
TaskTemp work_orderTemp = taskTempSerrvice.getById(id);
if (work_orderTemp != null) {
return ResultUtil.success(work_orderTemp);
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);
}
......@@ -84,31 +106,35 @@ public class TaskTempController {
try {
TaskTemp taskTemp=new TaskTemp();
taskTemp.setStoreName(data.getStore_name());
taskTemp.setRepairPeople(data.getRepair_people());
taskTemp.setRepairPhone(data.getRepair_phone());
taskTemp.setRepairDate(data.getRepair_date());
taskTemp.setFaultDescription(data.getFault_description());
taskTemp.setStoreName(data.getStoreName());
taskTemp.setRepairPeople(data.getRepairPeople());
taskTemp.setRepairPhone(data.getRepairPhone());
taskTemp.setRepairDate(data.getRepairDate());
taskTemp.setFaultDescription(data.getFaultDescription());
//TaskTemp workOrder= taskTempDao.addTaskTemp(taskTemp);
TaskTemp saveTaskTemp= taskTempSerrvice.saveAndReturn(taskTemp);
if(saveTaskTemp!=null){
//添加文件附件
File file=new File();
file.setStoreId(0);//新增预处理订单还没有门店ID
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(data.getFilename());
file.setUrl(data.getFileurl());
file.setType(1);
// fileDao.addFile(file);
fileSerrvice.save(file);
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 ResultUtil.error(ResultEnum.SELECT_ERROR);
return e.getMessage();
}
}
......
package vion.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.*;
import com.dingtalk.api.response.*;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.taobao.api.ApiException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import vion.Global;
import vion.enums.ResultEnum;
import vion.model.Store;
......@@ -22,10 +29,7 @@ import vion.service.ITaskSerrvice;
import vion.service.IUserSerrvice;
import vion.utils.ResultUtil;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
@RestController
......@@ -57,11 +61,13 @@ public class UserController {
@ResponseBody
public Object getUserList(@RequestParam(name = "pageNum")Integer pageNum,
@RequestParam(name = "pageSize")Integer pageSize){
//pageNum当前页,pageSize每页条数
PageHelper.startPage(pageNum,pageSize);
Page page= PageHelper.startPage(pageNum,pageSize);
List<User> userList =userSerrvice.list();
PageInfo pageInfo=new PageInfo(userList,10);
userList.sort(Comparator.comparing(User::getId));
PageInfo pageInfo=new PageInfo<>(page);
pageInfo.setList(userList);
if (pageInfo != null) {
return ResultUtil.success(pageInfo);
......@@ -84,17 +90,40 @@ public class UserController {
}
}
@PostMapping("/login")
@ResponseBody
public Object getUser(@RequestBody User data){
try {
QueryWrapper<User> wrapper=new QueryWrapper<>();
wrapper.eq("username",data.getUsername());
wrapper.eq("password",data.getPassword());
User user=userSerrvice.getOne(wrapper);
if (user != null) {
Global.USERNAME_MAP.put(user.getUserid(),user);
return ResultUtil.success(user);
} else {
return ResultUtil.error(ResultEnum.SELECT_ERROR);
}
} catch (Exception e) {
return ResultUtil.error(ResultEnum.SELECT_ERROR);
}
}
@PostMapping("/users")
@ResponseBody
public Object getUserByID(User data){
public Object getUserByID(@RequestBody User data){
try {
if(data.getId()==null){
userSerrvice.save(data);
return ResultUtil.success();
}else{
data.setModifyTime(new Date());
User user=userSerrvice.saveAndReturn(data);
return ResultUtil.success(user);
User user1=userSerrvice.saveAndReturn(data);
return ResultUtil.success(user1);
}
}catch (Exception e) {
......@@ -210,10 +239,7 @@ public class UserController {
}
//钉钉消息推送
@GetMapping("/sendMessage")
@ResponseBody
public String messageInfo(@RequestParam(name="userid")String userid,
@RequestParam(name="task_id")Integer task_id){
public String sendMessage(String userid,Integer task_id){
DingTalkClient client=new DefaultDingTalkClient(dingurl+"/topapi/message/corpconversation/asyncsend_v2");
......
package vion.dao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import vion.model.Account;
import vion.model.File;
import vion.model.Store;
import java.util.List;
@Repository
public class AccountDao {
@Autowired
private JdbcTemplate jdbcTemplate;
private static final String SELECT_BY_UNID = "SELECT * FROM tbl_account_info WHERE id=?";
public Account getAccountById(Integer id) {
List<Account> accounts= jdbcTemplate.query(SELECT_BY_UNID, new BeanPropertyRowMapper<Account>(Account.class), new Object[]{id});
if(accounts.size()>0){
return accounts.get(0);
}else{
return null;
}
}
private static final String SELECT_ALL= "SELECT * FROM tbl_account_info";
public List<Account> getAccountAll() {
return jdbcTemplate.query(SELECT_ALL, new BeanPropertyRowMapper<Account>(Account.class));
}
private static final String SAVE_ACCOUNT= "INSERT INTO tbl_account_info(name,remark) VALUES (?, ?);";
public Integer addAccount(Account account) {
return jdbcTemplate.update(SAVE_ACCOUNT,
new Object[]{
account.getName(),account.getRemark()});
}
private static final String UPDATE_ACCOUNT= "UPDATE tbl_account_info\n" +
" SET name=?, modify_time=?, remark=?\n" +
" WHERE id=?;\n";
/*
public Integer updateAccount(Account account) {
return jdbcTemplate.update(UPDATE_ACCOUNT,
new Object[]{
account.getName(),account.getModify_time(),account.getRemark(),account.getId()});
}*/
}
package vion.dao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import vion.model.Account;
import vion.model.Dictionary;
import vion.model.DictionaryType;
import java.util.List;
@Repository
public class DictionaryDao {
@Autowired
private JdbcTemplate jdbcTemplate;
private static final String SELECT_DICTIONARY_BY_UNID = "SELECT * FROM tbl_dictionary_info WHERE id=?";
public Dictionary getDictionaryById(Integer id) {
List<Dictionary> dictionaries= jdbcTemplate.query(SELECT_DICTIONARY_BY_UNID, new BeanPropertyRowMapper<Dictionary>(Dictionary.class), new Object[]{id});
if(dictionaries.size()>0){
return dictionaries.get(0);
}else{
return null;
}
}
private static final String SELECT_DICTIONARY_ALL= "SELECT * FROM tbl_dictionary_info";
public List<Dictionary> getDictionaryAll() {
return jdbcTemplate.query(SELECT_DICTIONARY_ALL, new BeanPropertyRowMapper<Dictionary>(Dictionary.class));
}
private static final String SAVE_DICTIONARY= "INSERT INTO tbl_dictionary_info(\n" +
" type, key, value, remark)\n" +
" VALUES (?, ?, ?, ?);";
public Integer addDictionary(Dictionary dictionary) {
return jdbcTemplate.update(SAVE_DICTIONARY,
new Object[]{
dictionary.getType(),dictionary.getKey(),dictionary.getValue(),dictionary.getRemark()});
}
private static final String UPDATE_DICTIONARY= "UPDATE tbl_dictionary_info\n" +
" SET type=?, key=?, value=?, remark=?\n" +
" WHERE id=?;";
public Integer updateDictionary(Dictionary dictionary) {
return jdbcTemplate.update(UPDATE_DICTIONARY,
new Object[]{
dictionary.getType(),dictionary.getKey(),dictionary.getValue(),dictionary.getRemark(),dictionary.getId()});
}
private static final String SELECT_TYPE_BY_UNID = "SELECT * FROM tbl_dictionary_type WHERE id=?";
public DictionaryType getDictionaryTypeById(Integer id) {
List<DictionaryType> dictionaries= jdbcTemplate.query(SELECT_TYPE_BY_UNID, new BeanPropertyRowMapper<DictionaryType>(DictionaryType.class), new Object[]{id});
if(dictionaries.size()>0){
return dictionaries.get(0);
}else{
return null;
}
}
private static final String SELECT_DICTIONARYTYPE_ALL= "SELECT * FROM tbl_dictionary_type";
public List<DictionaryType> getDictionaryTypeAll() {
return jdbcTemplate.query(SELECT_DICTIONARYTYPE_ALL, new BeanPropertyRowMapper<DictionaryType>(DictionaryType.class));
}
private static final String SAVE_DICTIONARYTYPE= "INSERT INTO tbl_dictionary_type(\n" +
" type, name, remark)\n" +
" VALUES (?, ?, ?);";
public Integer addDictionaryType(DictionaryType dictionaryType) {
return jdbcTemplate.update(SAVE_DICTIONARYTYPE,
new Object[]{
dictionaryType.getType(),dictionaryType.getName(),dictionaryType.getRemark()});
}
private static final String UPDATE_DICTIONARYTYPE= "UPDATE tbl_dictionary_type\n" +
" SET type=?, name=?, remark=?\n" +
" WHERE id=?;";
public Integer updateDictionaryType(DictionaryType dictionaryType) {
return jdbcTemplate.update(UPDATE_DICTIONARYTYPE,
new Object[]{
dictionaryType.getType(),dictionaryType.getName(),dictionaryType.getRemark(),dictionaryType.getId()});
}
}
package vion.dao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import vion.model.Account;
import vion.model.File;
import vion.model.Store;
import java.util.List;
@Repository
public class FileDao {
@Autowired
private JdbcTemplate jdbcTemplate;
private static final String SELECT_FILE_ALL = "SELECT * FROM tbl_file_info";
public List<File> getFileAll() {
return jdbcTemplate.query(SELECT_FILE_ALL, new BeanPropertyRowMapper<File>(File.class));
}
private static final String SELECT_FILE_BY_SOURCEID = "SELECT * FROM tbl_file_info where store_id=? and source_id=?";
public List<File> getFileBySourceId(Integer store_id,Integer source_id) {
return jdbcTemplate.query(SELECT_FILE_BY_SOURCEID,new Object[]{store_id,source_id},
new BeanPropertyRowMapper<File>(File.class));
}
/*
private static final String SAVE_FILE= "INSERT INTO tbl_file_info(\n" +
" store_id, type, source_type, source_id, name, url)\n" +
" VALUES (?, ?, ?, ?, ?, ?);";
public Integer addFile(File file) {
return jdbcTemplate.update(SAVE_FILE,
new Object[]{file.getStore_id(),file.getType(),file.getSource_type(),
file.getSource_id(),file.getName(),file.getUrl()});
}
private static final String UPDATE_FILE= "UPDATE tbl_file_info\n" +
" SET store_id=? WHERE source_id=?";
public Integer updateFileStoreid(File file) {
return jdbcTemplate.update(UPDATE_FILE,
new Object[]{file.getStore_id(),file.getSource_id()});
}*/
}
package vion.dao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import vion.model.Inspect;
import java.util.Date;
import java.util.List;
@Repository
public class InspectDao {
@Autowired
private JdbcTemplate jdbcTemplate;
private static final String SELECT_INSPECT_ALL = "SELECT * FROM tbl_inspect_info";
public List<Inspect> getInspectAll() {
return jdbcTemplate.query(SELECT_INSPECT_ALL, new BeanPropertyRowMapper<Inspect>(Inspect.class));
}
private static final String SELECT_INSPECT_BY_ID = "SELECT * FROM tbl_inspect_info WHERE id=?";
public Inspect getInspectByID(Integer id) {
List<Inspect> inspects= jdbcTemplate.query(SELECT_INSPECT_BY_ID,new Object[]{id}, new BeanPropertyRowMapper<Inspect>(Inspect.class));
if(inspects.size()>0){
return inspects.get(0);
}else{
return null;
}
}
private static final String SELECT_INSPECT_BY_PARM= "SELECT * FROM tbl_inspect_info WHERE account_id=? ";
public List<Inspect> getInspectByParm(Integer account_id, Integer store_id, Date startdate,
Date enddate, Integer status) {
StringBuffer getInspectSb = new StringBuffer(SELECT_INSPECT_BY_PARM);
if(store_id!=null){
getInspectSb.append(" and store_id = "+store_id+"");
}
if(startdate!=null){
getInspectSb.append(" and inspect_date>='"+startdate+"'");
}
if(enddate!=null){
getInspectSb.append(" and inspect_date<='"+enddate+"'");
}
if(status!=null){
getInspectSb.append(" and status="+status+"");
}
return jdbcTemplate.query(getInspectSb.toString(),new Object[]{account_id}, new BeanPropertyRowMapper<Inspect>(Inspect.class));
}
/*
private static final String SAVE_INSPECT= "INSERT INTO tbl_inspect_info(\n" +
" store_id, inspect_date, type, status, inspect_user, reviewer, \n" +
" audit_date, finish_date, remark)\n" +
" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);";
public Integer addInspect(Inspect inspect) {
return jdbcTemplate.update(SAVE_INSPECT,
new Object[]{
inspect.getStore_id(),inspect.getInspect_date(),inspect.getType(),inspect.getStatus(),
inspect.getInspect_user(),inspect.getReviewer(),inspect.getAudit_date(),
inspect.getFinish_date(),inspect.getRemark()});
}
private static final String UPDATE_INSPECT= "UPDATE tbl_inspect_info\n" +
" SET store_id=?, inspect_date=?, type=?, status=?, inspect_user=?, \n" +
" reviewer=?, audit_date=?, finish_date=?, modify_time=?, \n" +
" remark=?\n" +
" WHERE id=?;";
public Integer updateInspect(Inspect inspect) {
return jdbcTemplate.update(UPDATE_INSPECT,
new Object[]{
inspect.getStore_id(),inspect.getInspect_date(),inspect.getType(),inspect.getStatus(),
inspect.getInspect_user(),inspect.getReviewer(),inspect.getAudit_date(),
inspect.getFinish_date(),inspect.getModify_time(),inspect.getRemark(),
inspect.getId()});
}
private static final String UPDATE_INSPECT_STATUS= "UPDATE tbl_inspect_info\n" +
" SET status=?,reviewer=?, audit_date=?, finish_date=?, modify_time=? \n" +
" WHERE id=?;";
public Integer updateInspectStatus(Inspect inspect) {
return jdbcTemplate.update(UPDATE_INSPECT_STATUS,
new Object[]{
inspect.getStatus(),inspect.getReviewer(),inspect.getAudit_date(),
inspect.getFinish_date(),inspect.getModify_time(),inspect.getId()});
}*/
}
package vion.dao;
import cn.hutool.core.util.StrUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import vion.model.File;
import vion.model.Product;
import vion.model.Store;
import java.util.Date;
import java.util.List;
@Repository
public class ProductDao {
@Autowired
private JdbcTemplate jdbcTemplate;
private static final String SELECT_PRODUCT_ALL = "SELECT * FROM tbl_product_info";
public List<Product> getProductAll() {
return jdbcTemplate.query(SELECT_PRODUCT_ALL, new BeanPropertyRowMapper<Product>(Product.class));
}
private static final String SELECT_PRODUCT_BY_ID = "SELECT * FROM tbl_product_info where id=?";
public Product getProductByID(Integer id) {
List<Product> products= jdbcTemplate.query(SELECT_PRODUCT_BY_ID,new Object[]{id},
new BeanPropertyRowMapper<Product>(Product.class));
if(products.size()>0){
return products.get(0);
}else{
return null;
}
}
private static final String SELECT_PRODUCT_BY_PARM= "SELECT * FROM tbl_product_info WHERE account_id=? and id=? ";
public List<Product> getProductByParm(Integer accountid, Integer id, String name, Integer brand, Integer functionary) {
StringBuffer getProductSb = new StringBuffer(SELECT_PRODUCT_BY_PARM);
if(!StrUtil.isBlank(name)){
getProductSb.append(" and name='"+name+"'");
}
if(brand!=null){
getProductSb.append(" and brand="+brand+"");
}
if(functionary!=null){
getProductSb.append(" and functionary="+functionary+"");
}
return jdbcTemplate.query(getProductSb.toString(),new Object[]{accountid,id}, new BeanPropertyRowMapper<Product>(Product.class));
}
private static final String SAVE_PRODUCT= "INSERT INTO tbl_product_info(\n" +
" material_no, store_id, name, functionary, brand, product_count, \n" +
" product_price, product_subtotal, product_total_price,remark,account_id)\n" +
" VALUES (?, ?, ?, ?, ?, ?, ?, \n" +
" ?, ?, ?,?);";
/*
public Integer addProduct(Product product) {
return jdbcTemplate.update(SAVE_PRODUCT,
new Object[]{product.getMaterial_no(),product.getStore_id(),product.getName(),
product.getFunctionary(),product.getBrand(),product.getProduct_count(),
product.getProduct_price(),product.getProduct_subtotal(),product.getProduct_total_price(),
product.getRemark(),product.getAccount_id()});
}
private static final String UPDATE_PRODUCT= "UPDATE tbl_product_info\n" +
" SET material_no=?, store_id=?, name=?, functionary=?, brand=?, \n" +
" product_count=?, product_price=?, product_subtotal=?, product_total_price=?, \n" +
" modify_time=?, remark=?,account_id=?\n" +
" WHERE id=?;";
public Integer updateProduct(Product product) {
return jdbcTemplate.update(UPDATE_PRODUCT,
new Object[]{product.getMaterial_no(),product.getStore_id(),product.getName(),
product.getFunctionary(),product.getBrand(),product.getProduct_count(),
product.getProduct_price(),product.getProduct_subtotal(),
product.getProduct_total_price(),product.getModify_time(),
product.getRemark(),product.getId(),product.getAccount_id()});
}*/
}
package vion.dao;
import cn.hutool.core.util.StrUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import vion.model.Address;
import vion.model.Store;
import vion.vo.StoreVO;
import java.util.Date;
import java.util.List;
@Repository
public class StoreDao {
@Autowired
private JdbcTemplate jdbcTemplate;
private static final String SELECT_STORE_ALL= "SELECT * FROM tbl_store_info";
public List<Store> getStoreAll() {
return jdbcTemplate.query(SELECT_STORE_ALL, new BeanPropertyRowMapper<Store>(Store.class));
}
private static final String SAVE_STORE= "INSERT INTO tbl_store_info(\n" +
" storenum, name, \"number\", contract_code, amount, orderdate, \n" +
" salesperson, warranty_period, customer_name, implement_type, \n" +
" project_state, contacts, create_user,remark, project_stage,account_id)\n" +
" VALUES (?, ?, ?, ?, ?, ?, \n" +
" ?, ?, ?, ?, ?,\n" +
" ?, ?, ?, ?, ?);";
public Integer addStore(StoreVO store) {
return jdbcTemplate.update(SAVE_STORE,
new Object[]{
store.getStorenum(),store.getName(),store.getNumber(),store.getContract_code(),store.getAmount(),
store.getOrderdate(),store.getSalesperson(),store.getWarranty_period(),store.getCustomer_name(),
store.getImplement_type(),store.getProject_state(),
store.getContacts(),store.getCreate_user(),store.getRemark(),
store.getProject_stage(),store.getAccount_id()});
}
private static final String UPDATE_STORE= "UPDATE tbl_store_info\n" +
" SET storenum=?, name=?, \"number\"=?, contract_code=?, amount=?, \n" +
" orderdate=?, salesperson=?, warranty_period=?, customer_name=?, \n" +
" implement_type=?, project_state=?, contacts=?, \n" +
" modify_user=?, modify_time=?, remark=?, \n" +
" project_stage=?,account_id=?\n" +
" WHERE id=?;";
public Integer updateStore(StoreVO store) {
return jdbcTemplate.update(UPDATE_STORE,
new Object[]{
store.getStorenum(),store.getName(),store.getNumber(),store.getContract_code(),store.getAmount(),
store.getOrderdate(),store.getSalesperson(),store.getWarranty_period(),store.getCustomer_name(),
store.getImplement_type(),store.getProject_state(),store.getContacts(),
store.getModify_user(),store.getModify_time(),store.getRemark(),store.getProject_stage(),
store.getAccount_id(),store.getId()});
}
private static final String UPDATE_STORE_STAGE= "UPDATE tbl_store_info SET project_stage=? WHERE id=?;";
public Integer updateStoreStage(Integer id,Integer project_stage) {
return jdbcTemplate.update(UPDATE_STORE_STAGE,
new Object[]{project_stage,id});
}
private static final String SELECT_STORE_BY_PARM= "SELECT * FROM tbl_store_info WHERE account_id=? and id=? ";
public List<Store> getStoreByParm(Integer accountid, Integer id, String storenum, Integer project_state,
String salesperson, Integer implement_type, Date startdate, Date enddate) {
StringBuffer getPlazaSb = new StringBuffer(SELECT_STORE_BY_PARM);
if(!StrUtil.isBlank(storenum)){
getPlazaSb.append(" and storenum='"+storenum+"'");
}
if(project_state!=null){
getPlazaSb.append(" and project_state="+project_state+"");
}
if(!StrUtil.isBlank(salesperson)){
getPlazaSb.append(" and salesperson='"+salesperson+"'");
}
if(implement_type!=null){
getPlazaSb.append(" and implement_type="+implement_type+"");
}
if(startdate!=null){
getPlazaSb.append(" and orderdate>='"+startdate+"'");
}
if(enddate!=null){
getPlazaSb.append(" and orderdate>='"+enddate+"'");
}
return jdbcTemplate.query(getPlazaSb.toString(),new Object[]{accountid,id}, new BeanPropertyRowMapper<Store>(Store.class));
}
private static final String SELECT_STORE_BY_ID= "select s.*,a.consignee_name,a.consignee_phone,a.consignee_address,a.contract_name,a.contract_phone,a.contract_address,a.invoice_name,a.invoice_phone,a.invoice_address,a.invoice_info \n" +
"from tbl_store_info as s left join tbl_address_info as a on a.store_id=s.id and s.id=?";
public StoreVO getStoreByID(Integer id) {
List<StoreVO> stores= jdbcTemplate.query(SELECT_STORE_BY_ID,new Object[]{id}, new BeanPropertyRowMapper<StoreVO>(StoreVO.class));
if(stores.size()>0){
return stores.get(0);
}else{
return null;
}
}
private static final String SAVE_ADDRESS= "INSERT INTO tbl_address_info(\n" +
" store_id, consignee_name, consignee_phone, consignee_address, \n" +
" contract_name, contract_phone, contract_address, invoice_name, \n" +
" invoice_phone, invoice_address, invoice_info)\n" +
" VALUES (?, ?, ?, ?, \n" +
" ?, ?, ?, ?, \n" +
" ?, ?, ?);";
public Integer addAddress(StoreVO address) {
return jdbcTemplate.update(SAVE_ADDRESS,
new Object[]{
address.getId(),address.getConsignee_name(),address.getConsignee_phone(),address.getConsignee_address(),
address.getContract_name(),address.getContract_phone(),address.getContract_address(),address.getInvoice_name(),
address.getInvoice_phone(),address.getInvoice_address(),address.getInvoice_info()
});
}
private static final String UPDATE_ADDRESS= "UPDATE tbl_address_info\n" +
" SET consignee_name=?, consignee_phone=?, consignee_address=?, \n" +
" contract_name=?, contract_phone=?, contract_address=?, invoice_name=?, \n" +
" invoice_phone=?, invoice_address=?, invoice_info=?\n" +
" WHERE store_id=?;";
public Integer updateAddress(StoreVO address) {
return jdbcTemplate.update(UPDATE_ADDRESS,
new Object[]{
address.getConsignee_name(),address.getConsignee_phone(),address.getConsignee_address(),
address.getContract_name(),address.getContract_phone(),address.getContract_address(),address.getInvoice_name(),
address.getInvoice_phone(),address.getInvoice_address(),address.getInvoice_info(),address.getId()
});
}
}
package vion.dao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import vion.model.FaultLog;
import vion.model.Task;
import java.util.Date;
import java.util.List;
@Repository
public class TaskDao {
@Autowired
private JdbcTemplate jdbcTemplate;
private static final String SELECT_WORKORDRE_ALL = "SELECT * FROM tbl_task_info";
public List<Task> getTaskAll() {
return jdbcTemplate.query(SELECT_WORKORDRE_ALL, new BeanPropertyRowMapper<Task>(Task.class));
}
private static final String SELECT_WORKORDRE_BY_ID = "SELECT * FROM tbl_task_info where id=?";
public Task getTaskByID(Integer id) {
List<Task> tasks= jdbcTemplate.query(SELECT_WORKORDRE_BY_ID,new Object[]{id},
new BeanPropertyRowMapper<Task>(Task.class));
if(tasks.size()>0){
return tasks.get(0);
}else{
return null;
}
}
private static final String SELECT_WORKORDRE_BY_PARM= "SELECT * FROM tbl_task_info WHERE account_id=?";
public List<Task> getTaskByParm(Integer accountid,Integer store_id, Date startdate,
Date enddate,Integer status,Integer fault_type) {
StringBuffer getTaskSb = new StringBuffer(SELECT_WORKORDRE_BY_PARM);
if(store_id!=null){
getTaskSb.append(" and store_id = "+store_id+"");
}
if(startdate!=null){
getTaskSb.append(" and repair_date>='"+startdate+"'");
}
if(enddate!=null){
getTaskSb.append(" and repair_date<='"+enddate+"'");
}
if(status!=null){
getTaskSb.append(" and status="+status+"");
}
if(fault_type!=null){
getTaskSb.append(" and fault_type="+fault_type+"");
}
return jdbcTemplate.query(getTaskSb.toString(),new Object[]{accountid},
new BeanPropertyRowMapper<Task>(Task.class));
}
private static final String SAVE_WORKORDRE= "INSERT INTO tbl_task_info(\n" +
" store_id, repair_date, fault_type, fault_description, repair_people, \n" +
" repair_phone, status, solve_date, fault_reason, solve_type, solve_description, \n" +
" create_user, remark,account_id)\n" +
" VALUES (?, ?, ?, ?, ?, ?, \n" +
" ?, ?, ?, ?, ?, ?, \n" +
" ?, ? );";
/*
public Task addTask(Task task) {
return jdbcTemplate.queryForObject(SAVE_WORKORDRE,
new Object[]{
task.getStore_id(),task.getRepair_date(),task.getFault_type(),
task.getFault_description(),task.getRepair_people(),task.getRepair_phone(),
task.getStatus(),task.getSolve_date(),task.getFault_reason(),task.getSolve_type(),
task.getSolve_description(),task.getCreate_user(),
task.getRemark(),task.getAccount_id()}
, new BeanPropertyRowMapper<Task>(Task.class));
}
private static final String UPDATE_WORKORDRE= "UPDATE tbl_task_info\n" +
" SET store_id=?, repair_date=?, fault_type=?, fault_description=?, \n" +
" repair_people=?, repair_phone=?, status=?, solve_date=?, fault_reason=?, \n" +
" solve_type=?, solve_description=?, create_user=?, \"current_user\"=?, \n" +
" modify_time=?, remark=?, account_id=?\n" +
" WHERE id=?;";
public Integer updateTask(Task task) {
return jdbcTemplate.update(UPDATE_WORKORDRE,
new Object[]{
task.getStore_id(),task.getRepair_date(),task.getFault_type(),
task.getFault_description(),task.getRepair_people(),task.getRepair_phone(),
task.getStatus(),task.getSolve_date(),task.getFault_reason(),task.getSolve_type(),
task.getSolve_description(),task.getCreate_user(),task.getCurrent_user(),
task.getModify_time(),task.getRemark(),task.getAccount_id(),task.getId()});
}
private static final String SELECT_FAULTLOG_BY_STOREID = "SELECT * FROM tbl_fault_log where store_id=? and workorder_id=?";
public FaultLog getFaultlogByStoreID(Integer store_id,Integer workorder_id) {
List<FaultLog> faultLogs= jdbcTemplate.query(SELECT_FAULTLOG_BY_STOREID,new Object[]{store_id,workorder_id},
new BeanPropertyRowMapper<FaultLog>(FaultLog.class));
if(faultLogs.size()>0){
return faultLogs.get(0);
}else{
return null;
}
}
private static final String SAVE_FAULTLOG= "INSERT INTO tbl_fault_log(\n" +
" store_id, workorder_id, operator, content, remark)\n" +
" VALUES (?, ?, ?, ?, ?);";
public Integer addFaultLog(FaultLog faultLog) {
return jdbcTemplate.update(SAVE_FAULTLOG,
new Object[]{
faultLog.getStore_id(),faultLog.getTask_id(),faultLog.getOperator(),
faultLog.getContent(),faultLog.getRemark()});
}*/
}
package vion.dao;
import cn.hutool.core.util.StrUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import vion.model.TaskTemp;
import java.util.Date;
import java.util.List;
@Repository
public class TaskTempDao {
@Autowired
private JdbcTemplate jdbcTemplate;
private static final String SELECT_WORK_TEMP_ALL = "SELECT * FROM tbl_task_temp";
public List<TaskTemp> getTaskTempAll() {
return jdbcTemplate.query(SELECT_WORK_TEMP_ALL, new BeanPropertyRowMapper<TaskTemp>(TaskTemp.class));
}
private static final String SELECT_WORK_TEMP_BY_ID = "SELECT * FROM tbl_task_temp where id=?";
public TaskTemp getTaskTempByID(Integer id) {
List<TaskTemp> taskTemps= jdbcTemplate.query(SELECT_WORK_TEMP_BY_ID,new Object[]{id}, new BeanPropertyRowMapper<TaskTemp>(TaskTemp.class));
if(taskTemps.size()>0){
return taskTemps.get(0);
}else{
return null;
}
}
private static final String SELECT_PRODUCT_BY_PARM= "SELECT * FROM tbl_product_info WHERE 1=1 ";
public List<TaskTemp> getTaskTempByParm(Integer store_id,String store_name, Date startdate, Date enddate, Integer status) {
StringBuffer getWorkOrderSb = new StringBuffer(SELECT_PRODUCT_BY_PARM);
if(!StrUtil.isBlank(store_name)){
getWorkOrderSb.append(" and store_name like '%"+store_name+"%'");
}
if(startdate!=null){
getWorkOrderSb.append(" and repair_date>='"+startdate+"'");
}
if(enddate!=null){
getWorkOrderSb.append(" and repair_date<='"+enddate+"'");
}
if(status!=null){
getWorkOrderSb.append(" and status="+status+"");
}
if(store_id!=null){
getWorkOrderSb.append(" and store_id="+store_id+"");
}
return jdbcTemplate.query(getWorkOrderSb.toString(),new BeanPropertyRowMapper<TaskTemp>(TaskTemp.class));
}
private static final String SAVE_WORK_ORDER_TEMP= "INSERT INTO tbl_task_temp(\n" +
" store_name, repair_date, fault_description, repair_people, \n" +
" repair_phone, status, operator, remark)\n" +
" VALUES (?, ?, ?, ?, ?, \n" +
" ?, ?, ?, ?, ?) RETURNING *;";//
/*
public TaskTemp addTaskTemp(TaskTemp order_temp) {
return jdbcTemplate.queryForObject(SAVE_WORK_ORDER_TEMP,
new Object[]{order_temp.getStore_name(),order_temp.getRepair_date(),order_temp.getFault_description(),
order_temp.getRepair_people(),order_temp.getRepair_phone(),order_temp.getStatus(),
order_temp.getOperator(),order_temp.getRemark()},
new BeanPropertyRowMapper<TaskTemp>(TaskTemp.class));
}
private static final String UPDATE_WORK_ORDER_TEMP= "UPDATE tbl_task_temp\n" +
" SET status=?, operator=?, modify_time=?" +
" WHERE id=?";
public Integer updateTaskTemp(TaskTemp order_temp) {
return jdbcTemplate.update(UPDATE_WORK_ORDER_TEMP,
new Object[]{order_temp.getStatus(),order_temp.getOperator(),
order_temp.getModify_time(),order_temp.getId()});
}*/
}
package vion.dao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import vion.model.User;
import java.util.List;
@Repository
public class UserDao {
@Autowired
private JdbcTemplate jdbcTemplate;
private static final String SELECT_USER_ALL = "SELECT * FROM tbl_user_info";
public List<User> getUserAll() {
return jdbcTemplate.query(SELECT_USER_ALL, new BeanPropertyRowMapper<User>(User.class));
}
private static final String SELECT_USER_BY_ID = "SELECT * FROM tbl_user_info where id=?";
public User getUserById(Integer id) {
return jdbcTemplate.queryForObject(SELECT_USER_BY_ID,new Object[]{id}, new BeanPropertyRowMapper<User>(User.class));
}
private static final String SELECT_USER_BY_USERID = "SELECT * FROM tbl_user_info where userid=?";
//根据钉钉存的userid判断是否存在
public User getUserByUserid(String userid) {
List<User> users= jdbcTemplate.query(SELECT_USER_BY_USERID,new Object[]{userid}, new BeanPropertyRowMapper<User>(User.class));
if(users.size()>0){
return users.get(0);
}else{
return null;
}
}
private static final String SAVE_USER= "INSERT INTO tbl_user_info(\n" +
" userid, username, phone)\n" +
" VALUES (?, ?, ?);";
public Integer addUser(User user) {
return jdbcTemplate.update(SAVE_USER,
new Object[]{user.getUserid(),user.getUsername(),user.getPhone()});
}
/*
private static final String UPDATE_USER= "UPDATE tbl_user_info\n" +
" SET username=?, phone=?,modify_time=?" +
" WHERE userid=? \n";
public Integer updateUserByUserid(User user) {
return jdbcTemplate.update(UPDATE_USER,
new Object[]{user.getUsername(),user.getPhone(),user.getModify_time(),user.getUserid()});
}
private static final String UPDATE_USER_PASS= "UPDATE tbl_user_info\n" +
" SET password=?,modify_time=?,remark=? " +
" WHERE userid=? \n";
public Integer updateUserPassByUserid(User user) {
return jdbcTemplate.update(UPDATE_USER_PASS,
new Object[]{user.getPassword(),user.getModify_time(),user.getRemark(),user.getUserid()});
}*/
}
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 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 {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
String url = request.getRequestURI();
System.out.println("拦截器");
if(url.indexOf("login") >= 0){
return true;
}
User user= Global.USERNAME_MAP.get(request.getHeader("userid"));
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));
pw.flush();
pw.close();
return false;
}
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;
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
@Bean
public Interceptor interceptor() {
return new Interceptor();
}
@Override
public void addInterceptors(InterceptorRegistry registry){
registry.addInterceptor(interceptor()).addPathPatterns("/api/**").excludePathPatterns("/api/login")
.excludePathPatterns("/error");//.excludePathPatterns("/api/downLoadFile");
}
}
......@@ -21,7 +21,7 @@ public class Product {
private Integer productCount;//订货数量
private Float productPrice;//订货单价
private Float productSubtotal;//定后价小计(单价乘以数量)
private Float productTotal_price;//订货总价
private Float productTotalPrice;//订货总价
private Date createTime;//创建时间
private Date modifyTime;//修改时间
private String remark;//备注
......
......@@ -22,7 +22,7 @@ public class Task {
private Integer solveType;//解决措施:0产品BUG、1使用问题、2需求问题
private String solveDescription;//解决故障描述
private Integer createUser;//创建者
private Integer currentuser;//当前处理人
private Integer activeUser;//当前处理人
private Date createTime;//创建时间
private Date modifyTime;//修改时间
private String remark;//备注
......
......@@ -7,11 +7,11 @@ import java.util.Date;
@Data
public class FaultLogVO {
private Integer id;//自增列
private Integer store_id;//门店id(外键)
private Integer task_id;//工单id(外键)
private Integer storeId;//门店id(外键)
private Integer taskId;//工单id(外键)
private Integer operator;//操作者
private String content;//操作内容
private Date create_time;//创建时间
private Date createTime;//创建时间
private String remark;//备注
private String filename;//文件名称
private String fileurl;//文件url
......
package vion.vo;
import lombok.Data;
import java.util.Date;
@Data
public class ProductVO {
private Integer id;//自增列
private String materialNo;//物料编号
private Integer storeId;//门店id(外键)
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 Date createTime;//创建时间
private Date modifyTime;//修改时间
private String remark;//备注
private Integer accountId;//集团id
}
......@@ -6,11 +6,11 @@ import java.util.Date;
@Data
public class StatusVO {
private Integer store_id;//门店id
private Integer project_stage;//阶段
private Integer source_type;//文件来源
private Integer source_id;//来源id
private Integer file_type;//文件类型
private Integer storeId;//门店id
private Integer projectStage;//阶段
private Integer sourceType;//文件来源
private Integer sourceId;//来源id
private Integer type;//文件类型
private String name;//名称
private String url;//地址
}
package vion.vo;
import lombok.Data;
import java.util.Date;
@Data
public class StoreListVO {
private Integer id;
private String name ;// 门店名称
}
......@@ -10,32 +10,32 @@ public class StoreVO {
private String storenum;
private String name ;// 门店名称
private String number;// 流水号
private String contract_code;//合同编码
private String contractCode;//合同编码
private Float amount;// 合同金额
private Date orderdate;//签订日期
private Integer salesperson;//销售人
private Integer warranty_period;//质保期
private String customer_name;//客户姓名
private Integer implement_type;//实施类型:0纯供货、1供货+安装、3续保、4维修
private Integer project_state;//项目状态:0待确认、1进行中、2已完成、3挂起
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 create_user;//创建者
private Integer modify_user;//修改者
private Date create_time;//创建时间
private Date modify_time;//修改时间
private Integer createUser;//创建者
private Integer modifyUser;//修改者
private Date createTime;//创建时间
private Date modifyTime;//修改时间
private String remark;//备注
private Integer project_stage;//项目阶段
private Integer account_id;//集团id
private Integer projectStage;//项目阶段
private Integer accountId;//集团id
//地址信息
private String consignee_name;//收货名称
private String consignee_phone;//收货手机号
private String consignee_address;//收货地址
private String contract_name;//合同姓名
private String contract_phone;//合同手机号
private String contract_address;//合同地址
private String invoice_name ;//发票姓名
private String invoice_phone;//发票手机号
private String invoice_address;//发票地址
private String invoice_info;//开票信息
private String consigneeName;//收货名称
private String consigneePhone;//收货手机号
private String consigneeAddress;//收货地址
private String contractName;//合同姓名
private String contractPhone;//合同手机号
private String contractAddress;//合同地址
private String invoiceName ;//发票姓名
private String invoicePhone;//发票手机号
private String invoiceAddress;//发票地址
private String invoiceInfo;//开票信息
}
package vion.vo;
import lombok.Data;
import vion.model.File;
import java.util.Date;
import java.util.List;
@Data
public class TaskTempVO {
private Integer id;//自增列
private String store_name;//项目名称
private Date repair_date;//报修日期
private String fault_description;//故障说明
private String repair_people;//报修人
private String repair_phone;//联系方式
private String storeName;//项目名称
private Date repairDate;//报修日期
private String faultDescription;//故障说明
private String repairPeople;//报修人
private String repairPhone;//联系方式
private Integer status;//状态(1待确认、2已确认)
private Date createTime;
private String filename;//文件名称
private String fileurl;//文件url
private List<File> fileList;//附件信息
// private String filename;//文件名称
// private String fileurl;//文件url
}
package vion.vo;
import lombok.Data;
import vion.model.File;
import java.util.Date;
import java.util.List;
@Data
public class TaskVO {
private Integer id;//自增列
private Integer store_id;//门店id(外键)
private Integer worktemp_id;//预处理工单id
private Date repair_date;//报修日期
private Integer fault_type;//故障类型
private String fault_description;//故障说明
private Integer repair_people;//报修人
private String repair_phone;//报修人联系方式
private Integer storeId;//门店id(外键)
private String storeName;//门店名称
private Integer tasktempId;//预处理工单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 solve_date;//解决日期
private String fault_reason;//故障原因
private Integer solve_type;//解决措施:0产品BUG、1使用问题、2需求问题
private String solve_description;//解决故障描述
private Integer create_user;//创建者
private Integer currentuser;//当前处理人
private Date create_time;//创建时间
private Date modify_time;//修改时间
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 account_id;//集团id
private String filename;//文件名称
private String fileurl;//文件url
private Integer accountId;//集团id
private List<File> fileList;//附件信息
// private String filename;//文件名称
// private String fileurl;//文件url
}
......@@ -5,8 +5,8 @@ spring.datasource.username=vion
spring.datasource.password=jkou72j32m4K5d8k
spring.datasource.driver-class-name=org.postgresql.Driver
server.port=8011
#fileurl=D:/pic
fileurl=/mnt/vdb1/vion/task/taskpic
fileurl=D:/pic
#fileurl=/nas-data/work-order
agentid=2358374016
appkey=dingkrzwks0jpi2di3uo
appsecret=Ul5UTZqIost_kEAdfZXidvLoZhzvraYurm_g7PCHg-IrDMLHT7mdSgRS1iCHrDPt
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!