初始版本

This commit is contained in:
suncz
2024-04-29 17:04:35 +08:00
commit b174c04733
1701 changed files with 349852 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
package com.vverp.controller.admin;
import com.vverp.dto.AddressDTO;
import com.vverp.moli.util.RespData;
import com.vverp.util.AddressUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* 地址解析
*
* @author dealsky
* @date 2020/7/29 2:59 下午
*/
@RequestMapping("/admin/address")
@Controller("adminAddressController")
public class AddressController extends BaseController {
@RequestMapping("/search")
@ResponseBody
public RespData search (String address, String region) {
AddressDTO addressDTO = AddressUtils.addressInfo(address, region);
return RespData.success(addressDTO);
}
}

View File

@@ -0,0 +1,284 @@
package com.vverp.controller.admin;
import com.vverp.dto.AdminQuery;
import com.vverp.entity.*;
import com.vverp.enums.Education;
import com.vverp.enums.NationalityType;
import com.vverp.enums.Reservoir;
import com.vverp.enums.WorkingState;
import com.vverp.service.*;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.*;
import com.vverp.moli.util.*;
import org.springframework.web.multipart.MultipartFile;
/**
* Controller - 管理员
*
* @author
* @version 1.0
*/
@Controller("admin")
@RequestMapping("/admin/admin")
public class AdminController extends BaseController {
@Resource
private AdminService adminService;
@Resource
private RoleService roleService;
@Resource
private DepartmentService departmentService;
@Resource
private CompanyService companyService;
@Resource
private ProgressService progressService;
@Resource
private ProductTypeService productTypeService;
@Resource
private SupplierService supplierService;
@RequestMapping(value = "/list")
public String list(Pageable pageable, ModelMap model, AdminQuery query) {
Page<Admin> page = adminService.findPageView(pageable, query);
model.addAttribute("page", page);
model.addAttribute("query", query);
model.addAttribute("departmentList", departmentService.findAll());
model.addAttribute("companyList", companyService.findAll());
return "/admin/list";
}
@RequestMapping(value = "/add")
public String add(ModelMap model) {
List<Role> roles = roleService.findAll();
model.addAttribute("sexs", Admin.Sex.values());
model.addAttribute("roles", roles);
model.addAttribute("departments", departmentService.findAll());
model.addAttribute("nationalityTypes", NationalityType.values());
model.addAttribute("educations", Education.values());
model.addAttribute("workingStates", WorkingState.values());
model.addAttribute("companyList", companyService.findAll());
model.addAttribute("productTypeList", productTypeService.findAll());
model.addAttribute("reservoirs", Reservoir.values());
return "/admin/add";
}
@RequestMapping("/usernameIsExist")
@ResponseBody
public boolean usernameIsExist(String username) {
if (StringUtils.isEmpty(username)) {
return false;
} else {
return !adminService.usernameIsExist(username);
}
}
@RequestMapping(value = "/edit")
public String edit(Long id, ModelMap model) {
Admin admin = adminService.find(id);
model.addAttribute("admin", admin);
model.addAttribute("sexs", Admin.Sex.values());
model.addAttribute("roles", roleService.findAll());
model.addAttribute("departments", departmentService.findAll());
model.addAttribute("nationalityTypes", NationalityType.values());
model.addAttribute("educations", Education.values());
model.addAttribute("workingStates", WorkingState.values());
model.addAttribute("companyList", companyService.findAll());
model.addAttribute("productTypeList", productTypeService.findAll());
model.addAttribute("reservoirs", Reservoir.values());
return "/admin/edit";
}
@RequestMapping(value = "/save", method = RequestMethod.POST)
public @ResponseBody
Message save(Admin admin, Long[] roleId, Long[] visibleCompanyId, Long[] visibleDepartmentId) {
try {
admin.setVisibleCompanyIdsStrByArr(visibleCompanyId);
admin.setVisibleDepartmentIdsStrByArr(visibleDepartmentId);
adminService.saveAdmin(admin, roleId);
} catch (RuntimeException e) {
return Message.error(e.getMessage());
}
return SUCCESS;
}
@RequestMapping(value = "/update", method = RequestMethod.POST)
public @ResponseBody
Message update(Admin admin, Long[] roleId, Long[] visibleCompanyId, Long[] visibleDepartmentId) {
try {
admin.setVisibleCompanyIdsStrByArr(visibleCompanyId);
admin.setVisibleDepartmentIdsStrByArr(visibleDepartmentId);
adminService.updateAdmin(admin, roleId);
} catch (RuntimeException e) {
return Message.error(e.getMessage());
}
return SUCCESS;
}
@RequestMapping(value = "/delete", method = RequestMethod.POST)
public @ResponseBody
Message delete(Long ids) {
if (!StringUtils.isEmpty(ids.toString())) {
Admin admin = adminService.find(ids);
if (admin != null) {
if (admin.getUsername().equals("admin"))
return Message.error("系统管理员无法删除");
}
}
adminService.delete(ids);
return SUCCESS;
}
@RequestMapping(value = "/reset", method = RequestMethod.POST)
@ResponseBody
public Message reset(Long id) {
if (!StringUtils.isEmpty(id.toString())) {
Admin admin = adminService.find(id);
if (admin != null) {
admin.setPassword(DigestUtils.md5Hex("123456"));
adminService.update(admin);
}
} else {
return Message.error("重置密码失败");
}
return SUCCESS;
}
@RequestMapping(value = "/changePass")
public String changePass() {
return "/common/dialog/changePass";
}
@RequestMapping(value = "/doChangePass")
public @ResponseBody
Message doChangePass(String oldPass, String newPass) {
if (newPass == null || newPass.equals("")) {
return Message.error("新密码不能为空");
}
Admin admin = adminService.getCurrent();
if (admin == null) {
return Message.error("未登录");
}
Admin pAdmin = adminService.find(admin.getId());
if (pAdmin == null) {
return Message.error("账号不存在");
}
if (!DigestUtils.md5Hex(oldPass).equals(pAdmin.getPassword())) {
return Message.error("原密码错误");
} else {
pAdmin.setPassword(DigestUtils.md5Hex(newPass));
adminService.update(pAdmin);
}
return SUCCESS;
}
@RequestMapping("export")
public void export(String username, String name, String phone, Admin.Sex sex, Date createDateStart, Date createDateEnd, Boolean isEnabled, HttpServletResponse response) throws IOException {
adminService.export(username, name, phone, sex, createDateStart, createDateEnd, isEnabled, response);
}
/**
* 导入模板
*/
@RequestMapping("/exportTemplate")
public void exportTemplate(HttpServletResponse response) {
adminService.exportTemplate(response);
}
@RequestMapping("import")
@ResponseBody
public RespData importExcel(MultipartFile file) {
try {
adminService.importExcel(file);
return RespData.success();
} catch (RuntimeException e) {
return RespData.error(e.getMessage());
} catch (Exception e) {
return RespData.error("导入失败");
}
}
@RequestMapping("/listByDepartment")
@ResponseBody
public RespData listByDepartment(Long departmentId) {
List<Admin> list = adminService.findListByAttribute("department.id", departmentId);
return RespData.success(list);
}
@RequestMapping(value = "/changeProgress")
public String changeProgress(ModelMap modelMap) {
Admin admin = adminService.getCurrent();
List<Progress> progresses = progressService.findAll();
Map<Long,Progress> progressMap = new HashMap<>();
for (Progress progress : progresses){
progressMap.put(progress.getId(),progress);
}
List<Progress> progressList = new ArrayList<>();
if (admin.getSupplierList().size()>0){
modelMap.addAttribute("showCompany",false);
for (Supplier supplier : admin.getSupplierList()){
if (supplier.getProgressId() == null){
modelMap.addAttribute("showCompany",true);
}else {
if (progressMap.containsKey(supplier.getProgressId())) {
progressList.add(progressMap.get(supplier.getProgressId()));
}
}
}
modelMap.addAttribute("progressList",progressList);
}else {
modelMap.addAttribute("showCompany",true);
modelMap.addAttribute("progressList",progresses);
}
modelMap.addAttribute("nowProgressId",admin.getNowProgress());
return "/common/dialog/changeProgress";
}
@RequestMapping(value = "/doChangeProgress")
public @ResponseBody
Message doChangeProgress(Long progressId) {
Admin admin = adminService.getCurrent();
admin.setNowProgress(progressId);
adminService.update(admin);
return SUCCESS;
}
@RequestMapping("checkRole")
@ResponseBody
public RespData checkRole(String power){
Admin admin = adminService.getCurrent();
boolean canJump = false;
for (Role role : admin.getRoles()){
if (role.getAuthorities().contains(power)){
canJump = true;
break;
}
}
return RespData.success(canJump);
}
}

View File

@@ -0,0 +1,173 @@
package com.vverp.controller.admin;
import com.vverp.entity.Admin;
import com.vverp.entity.AdminPurchase;
import com.vverp.entity.AdminPurchaseProductType;
import com.vverp.entity.ProductType;
import com.vverp.moli.util.Message;
import com.vverp.moli.util.Page;
import com.vverp.moli.util.Pageable;
import com.vverp.moli.util.RespData;
import com.vverp.service.*;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RequestMapping("admin/adminPurchase")
@Controller("adminAdminPurchase")
public class AdminPurchaseController extends BaseController{
@Resource
private AdminPurchaseService adminPurchaseService;
@Resource
private AdminService adminService;
@Resource
private ProductTypeService productTypeService;
@Resource
private AdminPurchaseProductTypeService adminPurchaseProductTypeService;
@Resource
private ProgressService progressService;
@RequestMapping("list")
public String list(ModelMap modelMap, Pageable pageable,Long progressId){
Admin admin = adminService.getCurrent();
if (admin.getNowProgress() == null){
modelMap.addAttribute("company",true);
}else {
modelMap.addAttribute("company",false);
}
Page<AdminPurchase> page = adminPurchaseService.findPageView(pageable,progressId == null?admin.getNowProgress():progressId);
Map<Long,String> map = new HashMap<>();
for (AdminPurchase adminPurchase : page.getContent()){
String name = "";
for (AdminPurchaseProductType adminPurchaseProductType : adminPurchase.getAdminPurchaseProductTypeList()){
if (adminPurchaseProductType.getProductType().getTypeDescribe() != null) {
name += "<span>" + adminPurchaseProductType.getProductType().getName() + "(" + adminPurchaseProductType.getProductType().getTypeDescribe() + ");</span><br>";
}else {
name += "<span>" + adminPurchaseProductType.getProductType().getName() + ";</span><br>";
}
}
map.put(adminPurchase.getId(),name);
}
modelMap.addAttribute("map",map);
modelMap.addAttribute("page",page);
modelMap.addAttribute("progressId",progressId);
modelMap.addAttribute("progressList",progressService.findAll());
return "adminPurchase/list";
}
@RequestMapping("add")
public String add(ModelMap modelMap){
Admin admin = adminService.getCurrent();
modelMap.addAttribute("progressId",admin.getNowProgress());
modelMap.addAttribute("adminList",adminService.findAll());
modelMap.addAttribute("productTypeList",productTypeService.findAll());
return "adminPurchase/add";
}
@RequestMapping("edit")
public String edit(ModelMap modelMap, Long id){
Admin admin = adminService.getCurrent();
modelMap.addAttribute("progressId",admin.getNowProgress());
AdminPurchase adminPurchase = adminPurchaseService.find(id);
List<Long> ids = new ArrayList<>();
for (AdminPurchaseProductType adminPurchaseProductType : adminPurchase.getAdminPurchaseProductTypeList()){
ids.add(adminPurchaseProductType.getProductType().getId());
}
modelMap.addAttribute("ids",ids);
modelMap.addAttribute("adminList",adminService.findAll());
modelMap.addAttribute("adminPurchase",adminPurchase);
modelMap.addAttribute("productTypeList",productTypeService.findAll());
return "adminPurchase/edit";
}
@RequestMapping("save")
@ResponseBody
public RespData save(AdminPurchase adminPurchase,Long[] productTypeIds){
try {
adminPurchaseService.saveEntity(adminPurchase,productTypeIds);
}catch (Exception e){
e.printStackTrace();
return RespData.error(e.getMessage());
}
return RespData.success();
}
@RequestMapping("update")
@ResponseBody
public RespData update(AdminPurchase adminPurchase,Long[] productTypeIds){
// if (adminPurchase.getAdmin()==null || adminPurchase.getAdmin().getId() == null){
// return RespData.error("员工不能为空");
// }
// if (adminPurchase.getProductType()==null || adminPurchase.getProductType().getId() == null){
// return RespData.error("可采购类别不能为空");
// }
// Admin admin = adminService.find(adminPurchase.getAdmin().getId());
// adminPurchase.setAdmin(admin);
// ProductType productType = productTypeService.find(adminPurchase.getProductType().getId());
// adminPurchase.setProductType(productType);
try {
adminPurchaseService.updateEntity(adminPurchase,productTypeIds);
}catch (Exception e){
e.printStackTrace();
return RespData.error(e.getMessage());
}
return RespData.success();
}
@RequestMapping("delete")
@ResponseBody
public Message delete(Long ids){
adminPurchaseService.delete(ids);
return Message.success("删除成功");
}
@RequestMapping("dialog/addFile")
public String dialogAddFile(ModelMap modelMap){
Admin admin = adminService.getCurrent();
modelMap.addAttribute("progressId",admin.getNowProgress());
return "adminPurchase/dialog/addFile";
}
@RequestMapping("/import")
@ResponseBody
public RespData importExcel(MultipartFile file,Long progressId) {
try {
adminPurchaseService.importExcel(file,progressId);
return RespData.success();
} catch (Exception e) {
e.printStackTrace();
return RespData.error(e.getMessage());
}
}
// /**
// * 导入模板
// */
// @RequestMapping("/exportTemplate")
// public void exportTemplate(HttpServletResponse response) {
// adminPurchaseService.exportTemplate(response);
// }
//
// @RequestMapping("import")
// @ResponseBody
// public RespData importExcel(MultipartFile file) {
// try {
// adminPurchaseService.importExcel(file);
// return RespData.success();
// } catch (RuntimeException e) {
// return RespData.error(e.getMessage());
// } catch (Exception e) {
// return RespData.error("导入失败");
// }
// }
}

View File

@@ -0,0 +1,27 @@
package com.vverp.controller.admin;
import com.vverp.entity.Area;
import com.vverp.service.AreaService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.List;
@Controller("area")
@RequestMapping(value = "/area")
public class AreaController extends BaseController {
@Resource
private AreaService areaService;
@RequestMapping("/dynamicLoading")
@ResponseBody
public List<Area> dynamicLoading(Long parentId, Integer grade){
Area parentBean = areaService.find(parentId);
List<Area> area = areaService.dynamicLoading(parentBean, grade);
return area;
}
}

View File

@@ -0,0 +1,171 @@
package com.vverp.controller.admin;
import cn.hutool.json.JSONUtil;
import com.vverp.base.Setting;
import com.vverp.entity.Admin;
import com.vverp.entity.AttachFile;
import com.vverp.enums.OrderAttachFileType;
import com.vverp.moli.util.Page;
import com.vverp.moli.util.Pageable;
import com.vverp.moli.util.RespData;
import com.vverp.service.AdminService;
import com.vverp.service.AttachFileService;
import com.vverp.service.UploadFileService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.*;
@Controller("adminAttachFileController")
@RequestMapping("/admin/attachFile")
public class AttachFileController extends BaseController {
@Resource
private AttachFileService attachFileService;
@Resource
private UploadFileService uploadFileService;
@Resource
private AdminService adminService;
@RequestMapping("list")
public String list(ModelMap modelMap, Pageable pageable, AttachFile.Type type){
Admin admin = adminService.getCurrent();
Page<AttachFile> page = attachFileService.findPageView(pageable,type,admin.getNowProgress());
modelMap.addAttribute("page",page);
return "attachFile/list";
}
@RequestMapping("/orderFileDialog")
public String orderFileDialog(ModelMap modelMap, Long[] fileIds, String attachFileWrapper, String source,
Long contentId, @RequestParam(defaultValue = "false") Boolean contractFlag) {
List<AttachFile> attachFileList = attachFileService.findList(fileIds);
modelMap.addAttribute("attachFileList", attachFileList);
modelMap.addAttribute("attachFileWrapper", attachFileWrapper);
modelMap.addAttribute("source", source);
modelMap.addAttribute("contentId", contentId);
modelMap.addAttribute("contractFlag", contractFlag);
modelMap.addAttribute("orderAttachFileTypes", OrderAttachFileType.values());
return "/attachFile/dialog/orderFileDialog";
}
@RequestMapping("/orderFileViewDialog")
public String orderFileViewDialog(ModelMap modelMap, Long[] fileIds,
@RequestParam(defaultValue = "false") Boolean contractFlag) {
List<AttachFile> attachFileList = attachFileService.findList(fileIds);
modelMap.addAttribute("attachFileList", attachFileList);
modelMap.addAttribute("contractFlag", contractFlag);
return "/attachFile/dialog/orderFileViewDialog";
}
@RequestMapping("/upload")
@ResponseBody
public RespData upload(MultipartFile file) {
if (file == null) {
return RespData.error("文件不存在");
}
try {
String fileName = uploadFileService.localUpload(file);
AttachFile attachFile = new AttachFile(file.getOriginalFilename(), file.getSize(), new Date(),
Setting.getData().getLocalStoragePath() + File.separator + fileName);
attachFileService.save(attachFile);
Map<String, Object> map = new HashMap<>();
map.put("attachFile", attachFile);
return RespData.success(map);
} catch (IOException e) {
e.printStackTrace();
return RespData.error("上传失败");
}
}
@RequestMapping("/uploadOss")
@ResponseBody
public RespData uploadOss(MultipartFile file, String source) {
if (file == null) {
return RespData.error("文件不存在");
}
String fileName = uploadFileService.ossUpload(file);
AttachFile attachFile = new AttachFile(file.getOriginalFilename(), file.getSize(), new Date(), fileName);
if (source != null) {
if (source.equals("supplier")) {
attachFile.setType(AttachFile.Type.supplier);
}else if (source.equals("purchaseOrder")){
attachFile.setType(AttachFile.Type.purchaseOrder);
}else if (source.equals("payment")){
attachFile.setType(AttachFile.Type.payment);
}else {
attachFile.setType(AttachFile.Type.other);
}
}
Admin admin = adminService.getCurrent();
attachFile.setProgressId(admin.getNowProgress());
attachFileService.save(attachFile);
Map<String, Object> map = new HashMap<>();
map.put("attachFile", attachFile);
return RespData.success(map);
}
@RequestMapping("/updateOrderAttachFileType")
@ResponseBody
public RespData updateOrderAttachFileType(Long id, OrderAttachFileType orderAttachFileType) {
AttachFile attachFile = attachFileService.find(id);
attachFile.setOrderAttachFileType(orderAttachFileType);
attachFileService.update(attachFile);
return RespData.success();
}
@RequestMapping("downloadFile")
public void downloadFile(HttpServletResponse response, Long id) {
AttachFile attachFile = attachFileService.find(id);
File file = new File(attachFile.getPath());
response.setCharacterEncoding("utf-8");
response.setContentType("multipart/form-data");
try {
response.addHeader("Content-Disposition",
"attachment;filename=" + new String(attachFile.getName().getBytes(), "ISO8859-1"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
try (FileInputStream inputStream = new FileInputStream(file);
OutputStream outputStream = response.getOutputStream()) {
byte[] buff = new byte[(int) file.length()];
inputStream.read(buff);
outputStream.write(buff);
outputStream.flush();
} catch (Exception e) {
e.printStackTrace();
}
}
@RequestMapping("/deleteFile")
@ResponseBody
public RespData deleteFile(Long id) {
attachFileService.deleteFile(id);
return RespData.success();
}
@RequestMapping("/deleteFileOss")
@ResponseBody
public RespData deleteFileOss(Long id) {
attachFileService.delete(id);
return RespData.success();
}
@RequestMapping("/updateSourceAttachFiles")
@ResponseBody
public RespData updateSourceAttachFiles(String source, Long contentId, String attachFieldsStr) {
List<Long> attachFields = JSONUtil.toList(JSONUtil.parseArray(attachFieldsStr), Long.class);
return respDataWithHandle(() -> attachFileService.updateSourceAttachFiles(source, contentId, attachFields));
}
}

View File

@@ -0,0 +1,33 @@
package com.vverp.controller.admin;
import com.vverp.entity.Supplier;
import com.vverp.moli.util.RespData;
import com.vverp.service.SupplierService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
/**
* @author dealsky
* @date 2020/8/28 9:48 上午
*/
@Controller("adminBankController")
@RequestMapping("/admin/bank")
public class BankController extends BaseController {
@Resource
private SupplierService supplierService;
@RequestMapping("/findList")
@ResponseBody
public RespData findList(String type, Long id) {
if (type.equals("supplier")) {
Supplier supplier = supplierService.find(id);
return RespData.success(supplier.getBankAccountList());
}
return RespData.success();
}
}

View File

@@ -0,0 +1,254 @@
/*
* Copyright 2013-2017 vverp.com. All rights reserved.
* Support: http://www.vverp.com
* License: http://www.vverp.com/license
*/
package com.vverp.controller.admin;
import com.vverp.dto.LayuiPage;
import com.vverp.entity.Log;
import com.vverp.util.PageUtils;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
import org.springframework.util.Assert;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import javax.annotation.Resource;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.Date;
import java.util.Map;
import java.util.Set;
import com.vverp.moli.util.*;
/**
* Controller - 基类
*
* @author
* @version 1.0
*/
public class BaseController {
/** Logger */
private final Logger logger = LoggerFactory.getLogger(getClass());
protected static final Message SUCCESS = Message.success("操作成功");
protected static final Message ERROR = Message.success("操作失败");
/** "验证结果"属性名称 */
private static final String CONSTRAINT_VIOLATIONS_ATTRIBUTE_NAME = "constraintViolations";
@Resource(name = "validator")
private Validator validator;
/**
* 数据绑定
*
* @param binder
* WebDataBinder
*/
@InitBinder
protected void initBinder(WebDataBinder binder) {
binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
binder.registerCustomEditor(Date.class, new DateEditor(true));
binder.registerCustomEditor(String.class, "password", new StringEditor(true));
}
@ExceptionHandler
@ResponseBody
public Message exceptionHandler(Exception exception) {
exception.printStackTrace();
return Message.error("异常", exception.getMessage());
}
/**
* 数据验证
*
* @param target
* 验证对象
* @param groups
* 验证组
* @return 验证结果
*/
protected boolean isValid(Object target, Class<?>... groups) {
Assert.notNull(target);
Set<ConstraintViolation<Object>> constraintViolations = validator.validate(target, groups);
if (constraintViolations.isEmpty()) {
return true;
}
RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();
requestAttributes.setAttribute(CONSTRAINT_VIOLATIONS_ATTRIBUTE_NAME, constraintViolations, RequestAttributes.SCOPE_REQUEST);
return false;
}
/**
* 数据验证
*
* @param targets
* 验证对象
* @param groups
* 验证组
* @return 验证结果
*/
protected boolean isValid(Collection<Object> targets, Class<?>... groups) {
Assert.notEmpty(targets);
for (Object target : targets) {
if (!isValid(target, groups)) {
return false;
}
}
return true;
}
/**
* 数据验证
*
* @param type
* 类型
* @param property
* 属性
* @param value
* 值
* @param groups
* 验证组
* @return 验证结果
*/
protected boolean isValid(Class<?> type, String property, Object value, Class<?>... groups) {
Assert.notNull(type);
Assert.hasText(property);
Set<?> constraintViolations = validator.validateValue(type, property, value, groups);
if (constraintViolations.isEmpty()) {
return true;
}
RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();
requestAttributes.setAttribute(CONSTRAINT_VIOLATIONS_ATTRIBUTE_NAME, constraintViolations, RequestAttributes.SCOPE_REQUEST);
return false;
}
/**
* 数据验证
*
* @param type
* 类型
* @param properties
* 属性
* @param groups
* 验证组
* @return 验证结果
*/
protected boolean isValid(Class<?> type, Map<String, Object> properties, Class<?>... groups) {
Assert.notNull(type);
Assert.notEmpty(properties);
for (Map.Entry<String, Object> entry : properties.entrySet()) {
if (!isValid(type, entry.getKey(), entry.getValue(), groups)) {
return false;
}
}
return true;
}
/**
* 货币格式化
*
* @param amount
* 金额
* @param showSign
* 显示标志
* @param showUnit
* 显示单位
* @return 货币格式化
*/
protected String currency(BigDecimal amount, boolean showSign, boolean showUnit) {
// Setting setting = SystemUtils.getSetting();
// String price = setting.setScale(amount).toString();
// if (showSign) {
// price = setting.getCurrencySign() + price;
// }
// if (showUnit) {
// price += setting.getCurrencyUnit();
// }
// return price;
return "";
}
/**
* 获取国际化消息
*
* @param code
* 代码
* @param args
* 参数
* @return 国际化消息
*/
protected String message(String code, Object... args) {
return SpringUtils.getMessage(code, args);
}
/**
* 添加日志
*
* @param content
* 内容
*/
protected void addLog(String content) {
if (content != null) {
RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();
requestAttributes.setAttribute(Log.LOG_CONTENT_ATTRIBUTE_NAME, content, RequestAttributes.SCOPE_REQUEST);
}
}
protected RespData respDataWithHandle(Runnable runnable) {
return respDataWithHandle(runnable, "操作失败");
}
protected RespData respDataWithHandle(Runnable runnable, String errorMsg) {
try {
runnable.run();
return RespData.success();
} catch (RuntimeException e) {
logger.error("controller error: {}", ExceptionUtils.getFullStackTrace(e));
return RespData.error(e.getMessage());
} catch (Exception e) {
logger.error("controller error: {}", ExceptionUtils.getFullStackTrace(e));
return RespData.error(errorMsg);
}
}
protected Message msgDataWithHandle(Runnable runnable) {
return msgDataWithHandle(runnable, "操作失败");
}
protected Message msgDataWithHandle(Runnable runnable, String errorMsg) {
try {
runnable.run();
return Message.success("success");
} catch (RuntimeException e) {
logger.error("controller error: {}", ExceptionUtils.getFullStackTrace(e));
return Message.error(e.getMessage());
} catch (Exception e) {
logger.error("controller error: {}", ExceptionUtils.getFullStackTrace(e));
return Message.error(errorMsg);
}
}
protected <T> LayuiPage<T> toLayuiPage(RespData respData) {
return PageUtils.toLayuiPage(respData);
}
}

View File

@@ -0,0 +1,193 @@
package com.vverp.controller.admin;
import com.vverp.entity.Admin;
import com.vverp.entity.ProductType;
import com.vverp.entity.Supplier;
import com.vverp.entity.BidArea;
import com.vverp.moli.util.Message;
import com.vverp.moli.util.Page;
import com.vverp.moli.util.Pageable;
import com.vverp.moli.util.RespData;
import com.vverp.service.*;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@RequestMapping("admin/bidArea")
@Controller("adminBidArea")
public class BidAreaController extends BaseController{
@Resource
private BidAreaService bidAreaService;
@Resource
private SupplierService supplierService;
@Resource
private ProductTypeService productTypeService;
@Resource
private DiameterService diameterService;
@Resource
private WallThicknessService wallThicknessService;
@Resource
private MaterialService materialService;
@Resource
private SizeStandardService sizeStandardService;
@Resource
private EndFaceService endFaceService;
@Resource
private PressureLevelService pressureLevelService;
@Resource
private AdminService adminService;
@RequestMapping("list")
public String list(ModelMap modelMap, Pageable pageable, String productTypeChan,String bigType,String smallType){
Admin admin = adminService.getCurrent();
Page<BidArea> page = bidAreaService.findPageView(pageable,productTypeChan,admin.getNowProgress(),bigType,smallType);
// Map<Long,String> typeChan = new HashMap<>();
// for (BidArea product : page.getContent()){
// if (product.getProductType() != null) {
// if (product.getProductType().getParentId() != null){
// ProductType parent = productTypeService.find(product.getProductType().getParentId());
// typeChan.put(product.getId(), parent.getName()+"/"+product.getProductType().getName());
// }else {
// typeChan.put(product.getId(), product.getProductType().getName());
// }
// }else {
// typeChan.put(product.getId(), "");
// }
// }
modelMap.addAttribute("page",page);
modelMap.addAttribute("bigType",bigType);
modelMap.addAttribute("smallType",smallType);
modelMap.addAttribute("productTypeChan",productTypeChan);
return "bidArea/list";
}
@RequestMapping("add")
public String add(ModelMap modelMap){
Admin admin = adminService.getCurrent();
modelMap.addAttribute("progressId",admin.getNowProgress());
modelMap.addAttribute("productTypeList",productTypeService.findListByAttribute("level",1));
modelMap.addAttribute("pressureLevelList",pressureLevelService.findAll());
modelMap.addAttribute("endFaceList",endFaceService.findAll());
modelMap.addAttribute("materialList",materialService.findAll());
modelMap.addAttribute("wallThicknessList",wallThicknessService.findAll());
modelMap.addAttribute("diameterList",diameterService.findAll());
modelMap.addAttribute("sizeStandardList",sizeStandardService.findAll());
return "bidArea/add";
}
@RequestMapping("edit")
public String edit(Long id,ModelMap modelMap){
BidArea bidArea = bidAreaService.find(id);
ProductType productType = productTypeService.find(bidArea.getBigTypeId());
modelMap.addAttribute("bigTypeList",productTypeService.findListByAttribute("level",1));
if (productType != null) {
modelMap.addAttribute("smallTypeList", productTypeService.findByParent(productType.getId()));
}else {
modelMap.addAttribute("smallTypeList", new ArrayList<>());
}
modelMap.addAttribute("bidArea",bidArea);
modelMap.addAttribute("pressureLevelList",pressureLevelService.findAll());
modelMap.addAttribute("endFaceList",endFaceService.findAll());
modelMap.addAttribute("materialList",materialService.findAll());
modelMap.addAttribute("wallThicknessList",wallThicknessService.findAll());
modelMap.addAttribute("diameterList",diameterService.findAll());
modelMap.addAttribute("sizeStandardList",sizeStandardService.findAll());
return "bidArea/edit";
}
@RequestMapping("save")
@ResponseBody
public Message save(BidArea bidArea){
try {
bidAreaService.saveEntity(bidArea);
return Message.success("保存成功");
}catch (Exception e){
return Message.error(e.getMessage());
}
}
@RequestMapping("update")
@ResponseBody
public Message update(BidArea bidArea){
try {
bidAreaService.updateEntity(bidArea);
return Message.success("保存成功");
}catch (Exception e){
return Message.error(e.getMessage());
}
}
@RequestMapping("delete")
@ResponseBody
public Message delete(Long[] ids){
bidAreaService.delete(ids);
return Message.success("删除成功");
}
@RequestMapping("dialog/addFile")
public String dialogAddFile(ModelMap modelMap){
modelMap.addAttribute("adminId",adminService.getCurrent().getId());
return "bidArea/dialog/addFile";
}
@RequestMapping(value = "/uploadExcel")
@ResponseBody
public RespData uploadExcel(MultipartFile file,Long adminId) {
if (file == null) {
return RespData.error("文件为空");
}
//获得文件名
String fileName = file.getOriginalFilename();
//判断文件是否是excel文件
if (!fileName.endsWith("xls") && !fileName.endsWith("xlsx")) {
return RespData.error("不是excel文件");
}
try {
Map<String,Object> map = bidAreaService.saveFile(file,adminId);
Integer repeatNum = Integer.valueOf(map.get("repeatNum").toString());
Integer failNum = Integer.valueOf(map.get("failNum").toString());
String msg = "导入成功,"+repeatNum+"条已存在";
map.put("msg",msg);
if (failNum == 0 && repeatNum ==0){
return RespData.success(map);
}
if (failNum>0) {
msg = failNum + "条导入失败";
}
map.put("msg",msg);
return RespData.warn(map);
}catch (Exception e){
e.printStackTrace();
return RespData.error(e.getMessage());
}
}
@RequestMapping("uploadResult")
public String uploadResult(ModelMap modelMap,Integer successNum, Integer repeatNum, Integer failNum){
modelMap.addAttribute("successNum",successNum);
modelMap.addAttribute("repeatNum",repeatNum);
modelMap.addAttribute("failNum",failNum);
return "bidArea/dialog/uploadResult";
}
@RequestMapping("exportNotFund")
public void exportNotFund(HttpServletResponse response) {
try {
bidAreaService.exportNotFund(response);
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,124 @@
package com.vverp.controller.admin;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.convert.NumberChineseFormater;
import com.vverp.base.Setting;
import com.vverp.entity.SystemSetting;
import com.vverp.moli.util.RespData;
import com.vverp.service.SystemSettingService;
import com.vverp.util.ImageUtils;
import com.vverp.util.PinyinUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.awt.*;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
/**
* @author dealsky
*/
@Controller("adminCommonController")
@RequestMapping("/admin/common")
public class CommonController {
@Resource
private SystemSettingService systemSettingService;
@RequestMapping("/selectTableField")
public String selectTableField(ModelMap modelMap, String name, Boolean range, Boolean fieldControl, Boolean filter) {
modelMap.put("table", name);
modelMap.put("range", range);
modelMap.put("fieldControl", fieldControl != null ? fieldControl : false);
modelMap.put("filter", filter != null ? filter : true);
return "common/dialog/selectTableField";
}
@RequestMapping("/fieldControl")
public String fieldControl(ModelMap modelMap, String name, Long roleId) {
modelMap.put("table", name);
modelMap.put("roleId", roleId);
return "common/dialog/fieldControl";
}
@RequestMapping("/selectInsideField")
public String selectInsideField(ModelMap modelMap, String name, Boolean range) {
modelMap.put("table", name);
modelMap.put("range", range);
return "common/dialog/selectInsideField";
}
@RequestMapping("/formSetting")
public String formSetting(ModelMap modelMap, String name, Integer index) {
modelMap.put("name", name);
modelMap.put("index", index);
return "common/dialog/formSetting";
}
@RequestMapping("/firstPinyin")
@ResponseBody
public RespData firstPinyin(String name) {
try {
return RespData.success(PinyinUtils.getFirstSpell(name).toUpperCase());
} catch (Exception e) {
return RespData.error("转换出错");
}
}
@RequestMapping("/genDefaultLogo")
@ResponseBody
public RespData genDefaultLogo() {
String logo = "/admin/common/defaultLogo";
SystemSetting systemSetting = systemSettingService.findSingle();
systemSetting.setLogo(logo);
systemSettingService.update(systemSetting);
Setting.load(systemSetting);
return RespData.success(logo);
}
@RequestMapping("/defaultLogo")
public void defaultLogo(HttpServletResponse response) {
try (ServletOutputStream outputStream = response.getOutputStream()) {
response.setContentType("image/png");
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
String name = Setting.getData().getSiteName();
if (StringUtils.isNotBlank(name)) {
name = name.substring(0, 1);
} else {
name = "E";
}
ImageUtils.create(byteArrayOutputStream, name, new Color(0x409eff));
outputStream.write(byteArrayOutputStream.toByteArray());
outputStream.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
@RequestMapping("/dialogArrangePlan")
public String dialogArrangePlan(Long id, ModelMap modelMap) {
modelMap.addAttribute("transportContractId", id);
return "/common/dialog/arrangePlan";
}
@RequestMapping("/numberChineseFormat")
@ResponseBody
public RespData numberChineseFormat(BigDecimal value) {
return RespData.success(NumberChineseFormater.format(value.doubleValue(), true, true));
}
@RequestMapping("/pageBox")
public String pageBox(ModelMap modelMap, String url) {
modelMap.addAttribute("url", new String(Base64.decode(url)));
modelMap.addAttribute("systemSetting", systemSettingService.findSingle());
return "/common/pageBox";
}
}

View File

@@ -0,0 +1,116 @@
package com.vverp.controller.admin;
import com.vverp.entity.Admin;
import com.vverp.entity.BaseEntity;
import com.vverp.entity.Company;
import com.vverp.entity.Department;
import com.vverp.moli.util.Message;
import com.vverp.moli.util.Order;
import com.vverp.moli.util.Pageable;
import com.vverp.moli.util.RespData;
import com.vverp.service.AdminService;
import com.vverp.service.CompanyService;
import com.vverp.util.MapUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.*;
@Controller("adminCompanyController")
@RequestMapping("/admin/company")
public class CompanyController extends BaseController {
@Resource
private CompanyService companyService;
@Resource
private AdminService adminService;
@RequestMapping(value = "/index")
public String index(Long id, ModelMap modelMap) {
return "/company/index";
}
@RequestMapping("/list")
public String list(Pageable pageable, ModelMap modelMap) {
modelMap.addAttribute("page", companyService.findPage(pageable));
return "/company/list";
}
@RequestMapping("/add")
public String add() {
return "/company/add";
}
@RequestMapping("/edit")
public String edit(ModelMap modelMap, Long id) {
Company company = companyService.find(id);
modelMap.addAttribute("company", company);
return "/company/edit";
}
@RequestMapping("/save")
@ResponseBody
public RespData save(Company company) {
try {
companyService.saveEntity(company);
} catch (RuntimeException e) {
return RespData.error(e.getMessage());
}
return RespData.success();
}
@RequestMapping("/update")
@ResponseBody
public RespData update(Company company) {
try {
companyService.updateEntity(company);
} catch (RuntimeException e) {
return RespData.error(e.getMessage());
}
return RespData.success();
}
@RequestMapping("/delete")
@ResponseBody
public Message list(Long[] ids) {
try {
companyService.deleteEntity(ids);
} catch (RuntimeException e) {
return Message.error(e.getMessage());
}
return SUCCESS;
}
@RequestMapping("/simpleList")
@ResponseBody
public RespData simpleList() {
return RespData.success(
MapUtils.beansToMapList(companyService.findList(null, null, Collections.singletonList(Order.asc("id"))), "id", "name", "shortName")
);
}
@RequestMapping("/listByCashier")
@ResponseBody
public RespData listByCashier() {
List<Company> companyList;
Admin admin = adminService.getCurrent();
Department department = admin.getDepartment();
if (department.getName().equals("总经办") || admin.getName().equals("润亿") || admin.getName().equals("潘彦娜")) {
companyList = companyService.findAll();
} else {
companyList = companyService.getListByCashier(admin.getName());
}
if (companyList == null) {
companyList = new ArrayList<>();
}
companyList.sort(Comparator.comparing(BaseEntity::getId));
return RespData.success(
MapUtils.beansToMapList(companyList, "id", "name", "shortName")
);
}
}

View File

@@ -0,0 +1,116 @@
package com.vverp.controller.admin;
import com.vverp.dto.AdminQuery;
import com.vverp.entity.Department;
import com.vverp.moli.util.Order;
import com.vverp.moli.util.Pageable;
import com.vverp.moli.util.RespData;
import com.vverp.service.AdminService;
import com.vverp.service.DepartmentService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* @author dealsky
* @date 2020/3/11 9:34 上午
*/
@Controller("adminDepartmentController")
@RequestMapping("/admin/department")
public class DepartmentController extends BaseController {
@Resource
private DepartmentService departmentService;
@Resource
private AdminService adminService;
@RequestMapping("/list")
public String list() {
return "/department/list";
}
@RequestMapping("/listAll")
@ResponseBody
public RespData listAll() {
Map<String, Object> map = new HashMap<>();
map.put("list", departmentService.findList(null, null, Collections.singletonList(Order.asc("sortFactor"))));
return RespData.success(map);
}
@RequestMapping("/dialog/add")
public String dialogAdd(ModelMap modelMap, String level, String parentId) {
modelMap.addAttribute("level", level);
modelMap.addAttribute("parentId", parentId);
modelMap.addAttribute("adminList", adminService.findAll());
return "/department/dialog/add";
}
@RequestMapping("/dialog/edit")
public String dialogEdit(ModelMap modelMap, Long id) {
modelMap.addAttribute("department", departmentService.find(id));
modelMap.addAttribute("adminList", adminService.findAll());
return "/department/dialog/edit";
}
@RequestMapping("/save")
@ResponseBody
public RespData save(Department department) {
try {
departmentService.saveDepartment(department);
} catch (RuntimeException e) {
e.printStackTrace();
return RespData.error(e.getMessage());
}
return RespData.success();
}
@RequestMapping("/update")
@ResponseBody
public RespData update(Department department) {
departmentService.updateDepartment(department);
return RespData.success();
}
@RequestMapping("/delete")
@ResponseBody
public RespData delete(Long id) {
Department department = departmentService.find(id);
try {
departmentService.deleteDepartment(department);
return RespData.success();
} catch (RuntimeException e) {
return RespData.error(e.getMessage());
}
}
@RequestMapping("/departmentTree")
@ResponseBody
public RespData departmentTree() {
Map<String, Object> map = new HashMap<>();
map.put("list", departmentService.departmentTree());
return RespData.success(map);
}
@RequestMapping("/structure")
public String structure(ModelMap modelMap, String departmentChain, Long treeId, Pageable pageable) {
AdminQuery query = new AdminQuery();
modelMap.addAttribute("page", adminService.findPageView(pageable, query));
modelMap.addAttribute("departmentChain", departmentChain);
modelMap.addAttribute("treeId", treeId);
return "/department/structure";
}
@RequestMapping("/selectTree")
@ResponseBody
public RespData selectTree() {
return RespData.success(departmentService.departmentTree());
}
}

View File

@@ -0,0 +1,92 @@
package com.vverp.controller.admin;
import com.vverp.entity.Diameter;
import com.vverp.moli.util.Message;
import com.vverp.moli.util.Page;
import com.vverp.moli.util.Pageable;
import com.vverp.moli.util.RespData;
import com.vverp.service.DiameterService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
@RequestMapping("admin/diameter")
@Controller("adminDiameter")
public class DiameterController extends BaseController{
@Resource
private DiameterService diameterService;
@RequestMapping("list")
public String list(ModelMap modelMap, Pageable pageable){
Page<Diameter> page = diameterService.findPage(pageable);
modelMap.addAttribute("page",page);
return "diameter/list";
}
@RequestMapping("add")
public String add(){
return "diameter/add";
}
@RequestMapping("edit")
public String edit(ModelMap modelMap, Long id){
Diameter diameter = diameterService.find(id);
modelMap.addAttribute("diameter",diameter);
return "diameter/edit";
}
@RequestMapping("save")
@ResponseBody
public RespData save(Diameter diameter){
if (diameterService.findByAttribute("name",diameter.getName()) != null){
return RespData.error(diameter.getName()+"已存在");
}
diameterService.save(diameter);
return RespData.success();
}
@RequestMapping("update")
@ResponseBody
public RespData update(Diameter diameter){
Diameter source = diameterService.findByAttribute("name",diameter.getName());
if (source != null && !source.getId().equals(diameter.getId())){
return RespData.error(diameter.getName()+"已存在");
}
diameterService.update(diameter);
return RespData.success();
}
@RequestMapping("delete")
@ResponseBody
public Message delete(Long ids){
diameterService.delete(ids);
return Message.success("删除成功");
}
/**
* 导入模板
*/
@RequestMapping("/exportTemplate")
public void exportTemplate(HttpServletResponse response) {
diameterService.exportTemplate(response);
}
@RequestMapping("import")
@ResponseBody
public RespData importExcel(MultipartFile file) {
try {
diameterService.importExcel(file);
return RespData.success();
} catch (RuntimeException e) {
return RespData.error(e.getMessage());
} catch (Exception e) {
return RespData.error("导入失败");
}
}
}

View File

@@ -0,0 +1,95 @@
package com.vverp.controller.admin;
import com.vverp.entity.EndFace;
import com.vverp.entity.SizeStandard;
import com.vverp.moli.util.Message;
import com.vverp.moli.util.Page;
import com.vverp.moli.util.Pageable;
import com.vverp.moli.util.RespData;
import com.vverp.service.EndFaceService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
@RequestMapping("admin/endFace")
@Controller("adminEndFace")
public class EndFaceController extends BaseController{
@Resource
private EndFaceService endFaceService;
@RequestMapping("list")
public String list(ModelMap modelMap, Pageable pageable){
Page<EndFace> page = endFaceService.findPage(pageable);
modelMap.addAttribute("page",page);
return "endFace/list";
}
@RequestMapping("add")
public String add(){
return "endFace/add";
}
@RequestMapping("edit")
public String edit(ModelMap modelMap, Long id){
EndFace endFace = endFaceService.find(id);
modelMap.addAttribute("endFace",endFace);
return "endFace/edit";
}
@RequestMapping("save")
@ResponseBody
public RespData save(EndFace endFace){
if (endFaceService.findByAttribute("name",endFace.getName()) != null){
return RespData.error(endFace.getName()+"已存在");
}
endFaceService.save(endFace);
return RespData.success();
}
@RequestMapping("update")
@ResponseBody
public RespData update(EndFace endFace){
EndFace source = endFaceService.findByAttribute("name",endFace.getName());
if (source != null && !source.getId().equals(endFace.getId())){
return RespData.error(endFace.getName()+"已存在");
}
endFaceService.update(endFace);
return RespData.success();
}
@RequestMapping("delete")
@ResponseBody
public Message delete(Long ids){
endFaceService.delete(ids);
return Message.success("删除成功");
}
/**
* 导入模板
*/
@RequestMapping("/exportTemplate")
public void exportTemplate(HttpServletResponse response) {
endFaceService.exportTemplate(response);
}
@RequestMapping("import")
@ResponseBody
public RespData importExcel(MultipartFile file) {
try {
endFaceService.importExcel(file);
return RespData.success();
} catch (RuntimeException e) {
return RespData.error(e.getMessage());
} catch (Exception e) {
return RespData.error("导入失败");
}
}
}

View File

@@ -0,0 +1,38 @@
package com.vverp.controller.admin;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* @author dealsky
* @date 2020/4/2 3:02 下午
*/
@Controller("adminExcelController")
@RequestMapping("/admin/excel")
public class ExcelController {
@RequestMapping("/dialog/import")
public String dialogImport(String url, String name, String template, ModelMap modelMap) {
modelMap.addAttribute("url", url);
modelMap.addAttribute("name", name);
modelMap.addAttribute("template", template);
return "/common/dialog/import";
}
@RequestMapping("/dialog/defaultImport")
public String dialogDefaultImport(String id, String name, ModelMap modelMap) {
modelMap.addAttribute("name", name);
modelMap.addAttribute("url", id + "/import.html");
modelMap.addAttribute("template", id + "/exportTemplate.html");
return "/common/dialog/import";
}
@RequestMapping("/dialog/uploadTemplate")
public String dialogUploadTemplate(String name, String template, ModelMap modelMap) {
modelMap.addAttribute("url", "excelTemplate/upload.html?name=" + name);
modelMap.addAttribute("template", template);
return "/common/dialog/uploadTemplate";
}
}

View File

@@ -0,0 +1,60 @@
package com.vverp.controller.admin;
import com.vverp.moli.util.RespData;
import com.vverp.service.ExcelTemplateService;
import org.springframework.stereotype.Controller;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.regex.Matcher;
/**
* @author dealsky
* @date 2020/4/8 2:47 下午
*/
@Controller("adminExcelTemplateController")
@RequestMapping("/admin/excelTemplate")
public class ExcelTemplateController {
@Resource
private ExcelTemplateService excelTemplateService;
@RequestMapping("/upload")
@ResponseBody
public RespData upload(String name, MultipartFile file) {
try {
excelTemplateService.upload(name, file);
return RespData.success();
} catch (Exception e) {
e.printStackTrace();
return RespData.error("上传失败");
}
}
@RequestMapping("/default")
public void defaultTemplate(String name, HttpServletResponse response) {
try {
File file = ResourceUtils.getFile(("classpath:excel/template/" + name).replaceAll("/", Matcher.quoteReplacement(File.separator)));
try (FileInputStream fileInputStream = new FileInputStream(file);
ServletOutputStream servletOutputStream = response.getOutputStream()) {
response.setHeader("Content-Disposition", "attachment;filename=" + file.getName());
byte[] bytes = new byte[fileInputStream.available()];
fileInputStream.read(bytes);
servletOutputStream.write(bytes);
} catch (IOException e) {
e.printStackTrace();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,85 @@
package com.vverp.controller.admin;
import com.alibaba.fastjson.JSONObject;
import com.vverp.annotation.Module;
import com.vverp.entity.Admin;
import com.vverp.entity.BaseEntity;
import com.vverp.entity.ExtraField;
import com.vverp.moli.util.RespData;
import com.vverp.service.AdminService;
import com.vverp.service.ExtraFieldService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
import org.springframework.core.type.filter.AssignableTypeFilter;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.*;
/**
* @author dealsky
* @date 2020/3/11 8:38 下午
*/
@Controller("adminExtraFieldController")
@RequestMapping("/admin/extraField")
public class ExtraFieldController extends BaseController {
@Resource
private ExtraFieldService extraFieldService;
@Resource
private AdminService adminService;
@RequestMapping("/list")
public String list(ModelMap modelMap) throws ClassNotFoundException {
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
provider.addIncludeFilter(new AssignableTypeFilter(BaseEntity.class));
Set<BeanDefinition> components = provider.findCandidateComponents("com.vverp.entity");
List<Map<String, Object>> list = new ArrayList<>();
for (BeanDefinition component : components) {
Map<String, Object> map = new HashMap<>();
Class cls = Class.forName(component.getBeanClassName());
if (!cls.getName().equals("com.vverp.entity.PurchaseApplyOrderItem")
&& !cls.getName().equals("com.vverp.entity.Supplier")
&& !cls.getName().equals("com.vverp.entity.MaterialOrderItem")){
continue;
}
String key = cls.getSimpleName();
key = key.substring(0, 1).toLowerCase() + key.substring(1);
Module module = (Module) cls.getAnnotation(Module.class);
if (module == null || StringUtils.isBlank(module.name())) {
continue;
}
map.put("key", key);
map.put("name", module.name());
list.add(map);
}
modelMap.addAttribute("list", list);
return "extraField/list";
}
@RequestMapping("/dialog/edit")
public String dialogEdit(ModelMap modelMap, String space, String title) {
Admin admin = adminService.getCurrent();
modelMap.addAttribute("space", space);
modelMap.addAttribute("title", title);
modelMap.addAttribute("list", extraFieldService.initData(space,admin.getNowProgress()));
return "/extraField/dialog/edit";
}
@RequestMapping("/extend")
@ResponseBody
public RespData extend(String extraFields, String space) {
Admin admin = adminService.getCurrent();
List<ExtraField> extraFieldList = JSONObject.parseArray(extraFields, ExtraField.class);
extraFieldService.update(extraFieldList, space,admin.getNowProgress());
return RespData.success();
}
}

View File

@@ -0,0 +1,71 @@
package com.vverp.controller.admin;
import com.vverp.base.Setting;
import com.vverp.moli.util.RespData;
import com.vverp.service.UploadFileService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
/**
* 文件上传
*/
@Controller("adminFileUploadController")
@CrossOrigin
@RequestMapping(value = "/admin/fileUpload")
public class FileUploadController {
@Resource
private UploadFileService uploadFileService;
@RequestMapping(value = "/upload")
@ResponseBody
public RespData upload(MultipartFile file) {
if (file == null) {
return RespData.error("文件不存在");
}
try {
String url = uploadFileService.ossUpload(file);
return RespData.success(url);
} catch (Exception e) {
return RespData.error("上传图片失败");
}
}
@RequestMapping(value = "/localUpload")
@ResponseBody
public RespData localUpload(MultipartFile file) {
if (file == null) {
return RespData.error("文件不存在");
}
try {
String url = uploadFileService.localUpload(file);
return RespData.success(url);
} catch (Exception e) {
return RespData.error("上传图片失败");
}
}
@RequestMapping(value = "/local")
public void local(String filename, HttpServletResponse response) {
File file = new File(Setting.getData().getLocalStoragePath(), filename);
if (file.exists()) {
try (FileInputStream fileInputStream = new FileInputStream(file);
ServletOutputStream outputStream = response.getOutputStream()) {
byte[] bytes = new byte[fileInputStream.available()];
fileInputStream.read(bytes);
outputStream.write(bytes);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

View File

@@ -0,0 +1,54 @@
package com.vverp.controller.admin;
import com.vverp.entity.FormStorage;
import com.vverp.moli.util.RespData;
import com.vverp.service.FormStorageService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
/**
* @author dealsky
*/
@Controller
@RequestMapping("/admin/formStorage")
public class FormStorageController extends BaseController {
@Resource
private FormStorageService formStorageService;
@RequestMapping("/getByName")
@ResponseBody
public RespData getColumns(String name) {
FormStorage formStorage = formStorageService.findByName(name);
Map<String, Object> data = new HashMap<>();
data.put("value", formStorage);
return RespData.success(data);
}
@RequestMapping("/save")
@ResponseBody
public RespData save(String name, String content) {
try {
FormStorage formStorage = formStorageService.findByName(name);
if (formStorage == null) {
formStorage = new FormStorage();
formStorage.setName(name);
formStorage.setContent(content);
formStorageService.save(formStorage);
} else {
formStorage.setContent(content);
formStorageService.update(formStorage);
}
return RespData.success();
} catch (Exception e) {
e.printStackTrace();
return RespData.error("出错了");
}
}
}

View File

@@ -0,0 +1,78 @@
package com.vverp.controller.admin;
import com.vverp.entity.GenerateSetting;
import com.vverp.moli.util.Message;
import com.vverp.moli.util.Pageable;
import com.vverp.moli.util.RespData;
import com.vverp.service.GenerateSettingService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
/**
* @author dealsky
* @date 2021-07-02 14:09
*/
@Controller
@RequestMapping("/admin/generateSetting")
public class GenerateSettingController extends BaseController {
@Resource
private GenerateSettingService generateSettingService;
@RequestMapping("/list")
public String list(ModelMap modelMap, Pageable pageable) {
modelMap.addAttribute("page", generateSettingService.findPage(pageable));
return "/generateSetting/list";
}
@RequestMapping("/add")
public String add() {
return "/generateSetting/add";
}
@RequestMapping("/edit")
public String edit(ModelMap modelMap, Long id) {
modelMap.addAttribute("generateSetting", generateSettingService.find(id));
return "/generateSetting/edit";
}
@RequestMapping("/dialog/list")
public String dialogList(ModelMap modelMap) {
modelMap.addAttribute("list", generateSettingService.findAll());
return "/generateSetting/dialog/list";
}
@RequestMapping("/dialog/add")
public String dialogAdd() {
return "/generateSetting/dialog/add";
}
@RequestMapping("/dialog/edit")
public String dialogEdit(ModelMap modelMap, Long id) {
modelMap.addAttribute("generateSetting", generateSettingService.find(id));
return "/generateSetting/dialog/edit";
}
@RequestMapping("/save")
@ResponseBody
public RespData save(GenerateSetting generateSetting) {
return respDataWithHandle(() -> generateSettingService.saveEntity(generateSetting));
}
@RequestMapping("/update")
@ResponseBody
public RespData update(GenerateSetting generateSetting) {
return respDataWithHandle(() -> generateSettingService.updateEntity(generateSetting));
}
@RequestMapping("/delete")
@ResponseBody
public Message delete(Long[] ids) {
return msgDataWithHandle(() -> generateSettingService.delete(ids));
}
}

View File

@@ -0,0 +1,112 @@
package com.vverp.controller.admin;
import com.vverp.entity.HelpInformation;
import com.vverp.moli.util.Message;
import com.vverp.moli.util.Page;
import com.vverp.moli.util.Pageable;
import com.vverp.moli.util.RespData;
import com.vverp.service.HelpInformationService;
import com.vverp.util.DateUtil;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RequestMapping("admin/helpInformation")
@Controller("adminHelpInformation")
public class HelpInformationController extends BaseController{
@Resource
private HelpInformationService helpInformationService;
@RequestMapping("/list")
public String list(ModelMap modelMap, Pageable pageable) {
Page<HelpInformation> page = helpInformationService.findPage(pageable);
modelMap.addAttribute("page", page);
return "/helpInformation/list";
}
@RequestMapping("/listForView")
public String listForView(ModelMap modelMap, Pageable pageable) {
Page<HelpInformation> page = helpInformationService.findPage(pageable);
modelMap.addAttribute("page", page);
return "/helpInformation/listForView";
}
@RequestMapping("/add")
public String add(ModelMap modelMap) {
modelMap.addAttribute("time", System.currentTimeMillis());
return "/helpInformation/add";
}
@RequestMapping("/save")
@ResponseBody
public Message save(HelpInformation helpInformation) {
try {
helpInformationService.save(helpInformation);
} catch (RuntimeException e) {
return Message.error(e.getMessage());
}
return SUCCESS;
}
@RequestMapping("/edit")
public String edit(ModelMap modelMap, Long id) {
modelMap.addAttribute("helpInformation", helpInformationService.find(id));
modelMap.addAttribute("time", System.currentTimeMillis());
return "/helpInformation/edit";
}
@RequestMapping("/update")
@ResponseBody
public Message update(HelpInformation helpInformation) {
try {
helpInformationService.update(helpInformation);
} catch (RuntimeException e) {
return Message.error(e.getMessage());
}
return SUCCESS;
}
@RequestMapping(value = "/delete", method = RequestMethod.POST)
public @ResponseBody
Message delete(Long[] ids) {
helpInformationService.delete(ids);
return SUCCESS;
}
@RequestMapping(value = "/dataList", method = RequestMethod.GET)
@ResponseBody
public RespData list(Pageable pageable) {
// Admin admin = adminService.getCurrent();
// Page<HelpInformationEntity> page = helpInformationEntityService.findPage(pageable, null);
Page<HelpInformation> page = helpInformationService.findPage(pageable);
List<Map<String, Object>> list = new ArrayList<>();
for (HelpInformation entity : page.getContent()) {
Map<String, Object> map = new HashMap<>();
map.put("id", entity.getId());
map.put("title", entity.getTitle());
map.put("date", DateUtil.format(entity.getCreateDate(), "yyyy-MM-dd"));
list.add(map);
}
return RespData.success(new Page<>(list, page.getTotal(), page.getPageable()));
}
@RequestMapping("getData")
@ResponseBody
public RespData getData(Long id){
return RespData.success(helpInformationService.find(id).getContent());
}
}

View File

@@ -0,0 +1,181 @@
package com.vverp.controller.admin;
import com.vverp.entity.*;
import com.vverp.moli.util.Page;
import com.vverp.moli.util.Pageable;
import com.vverp.util.DateUtil;
import com.vverp.enums.ApprovalSource;
import com.vverp.enums.Reservoir;
import com.vverp.moli.util.Filter;
import com.vverp.moli.util.Order;
import com.vverp.service.*;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
/**
* @author dealsky
* @date 2020/9/30 11:12 上午
*/
@Controller("adminHomeController")
@RequestMapping("/admin/home")
public class HomeController extends BaseController {
@Resource
private AdminService adminService;
@Resource
private CompanyService companyService;
@Resource
private ProductService productService;
@Resource
private PurchaseOrderService purchaseOrderService;
@Resource
private MaterialOrderService materialOrderService;
@Resource
private PurchaseApplyOrderService purchaseApplyOrderService;
@Resource
private PurchaseStockService purchaseStockService;
@RequestMapping("/index")
public String index(ModelMap modelMap) {
modelMap.addAttribute("companyList", companyService.findAll());
modelMap.addAttribute("sources", ApprovalSource.values());
return "/home/index";
}
@RequestMapping("/department")
public String department() {
Admin admin = adminService.getCurrent();
Department department = admin.getDepartment();
switch (department.getName()) {
case "商务执行部":
case "总经办": {
return "redirect:department/business.html";
}
case "市场营销部": {
return "redirect:department/market.html";
}
case "物流品控部": {
return "redirect:department/transport.html";
}
case "生产运行部": {
return "redirect:department/production.html";
}
case "单证综合部": {
return "redirect:department/invoice.html";
}
case "财务部": {
return "redirect:department/financial.html";
}
case "国际贸易部": {
return "redirect:department/internationalTrade.html";
}
default: {
//行政综合部
//资金部
return "redirect:department/general.html";
}
}
}
@RequestMapping("/department/business")
public String departmentBusiness(ModelMap modelMap) {
modelMap.addAttribute("companyList", companyService.findAll());
modelMap.addAttribute("productList", productService.findAll());
Admin admin = adminService.getCurrent();
String today = DateUtil.today();
modelMap.addAttribute("departmentValue", "business");
return "/home/department/business";
}
@RequestMapping("/department/market")
public String departmentMarket(ModelMap modelMap) {
modelMap.addAttribute("productList", productService.findAll());
modelMap.addAttribute("departmentValue", "market");
return "/home/department/market";
}
@RequestMapping("/department/transport")
public String departmentTransport(ModelMap modelMap) {
modelMap.addAttribute("reservoirs", Reservoir.values());
modelMap.addAttribute("departmentValue", "transport");
return "/home/department/transport";
}
@RequestMapping("/department/production")
public String departmentProduction(ModelMap modelMap) {
modelMap.addAttribute("departmentValue", "production");
return "/home/department/production";
}
@RequestMapping("/department/invoice")
public String departmentInvoice(ModelMap modelMap) {
// return "/home/department/invoice";
return "redirect:/admin/invoiceInventory/gasolineCombined";
}
@RequestMapping("/department/financial")
public String departmentFinancial(ModelMap modelMap) {
modelMap.addAttribute("companyList", companyService.findList(null, null, Collections.singletonList(Order.asc("id"))));
modelMap.addAttribute("ownerList", companyService.allCompanyList());
modelMap.addAttribute("departmentValue", "financial");
return "/home/department/financial";
}
@RequestMapping("/department/internationalTrade")
public String departmentInternationalTrade(ModelMap modelMap) {
modelMap.addAttribute("departmentValue", "internationalTrade");
modelMap.addAttribute("pricingList", purchaseOrderService.pricingList());
return "/home/department/internationalTrade";
}
@RequestMapping("/department/general")
public String departmentGeneral() {
return "/home/index";
}
@RequestMapping("dataBoard")
public String dataBoard(ModelMap modelMap){
return "home/dataBoard";
}
@RequestMapping("allList")
public String allList(ModelMap modelMap, Pageable pageable, String key, String value){
Page<MaterialOrder> page1 = materialOrderService.findPageByParams(pageable, key, value);
Page<PurchaseApplyOrder> page2 = purchaseApplyOrderService.findPageByParams(pageable, key, value);
Page<PurchaseStock> page3 = purchaseStockService.findPageByParams(pageable,key,value);
Page<PurchaseOrder> page4 = purchaseOrderService.findPageByParams(pageable,key,value);
long total = page1.getTotal();
if (page2.getTotal()>total){
total = page2.getTotal();
}
if (page3.getTotal()>total){
total = page3.getTotal();
}
if (page4.getTotal()>total){
total = page4.getTotal();
}
modelMap.addAttribute("page1",page1);
modelMap.addAttribute("page2",page2);
modelMap.addAttribute("page3",page3);
modelMap.addAttribute("page4",page4);
modelMap.addAttribute("key",key);
modelMap.addAttribute("value",value);
modelMap.addAttribute("page",new Page<>(new ArrayList<>(),total,pageable));
return "home/allList";
}
}

View File

@@ -0,0 +1,114 @@
package com.vverp.controller.admin;
import com.vverp.moli.util.RespData;
import com.vverp.service.ImportService;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.util.List;
/**
* 导入相关文件
*
* @author dealsky
* @date 2020/12/3 上午11:54
*/
@Controller
@RequestMapping("/admin/import")
public class ImportController extends BaseController {
private static final Logger logger = LoggerFactory.getLogger(ImportService.class);
@Resource
private ImportService importService;
@RequestMapping("/index")
public String index() {
return "/import/index";
}
@RequestMapping("/contractUpload")
@ResponseBody
public RespData contractUpload(MultipartFile file) {
try {
List<String> errorList = importService.contractUpload(file);
return RespData.success(errorList);
} catch (RuntimeException e) {
logger.error(ExceptionUtils.getFullStackTrace(e));
return RespData.error(e.getMessage());
} catch (Exception e) {
logger.error(ExceptionUtils.getFullStackTrace(e));
return RespData.error("导入失败");
}
}
@RequestMapping("/contractCheck")
@ResponseBody
public RespData contractCheck(MultipartFile file) {
try {
List<String> errorList = importService.contractCheck(file);
return RespData.success(errorList);
} catch (Exception e) {
logger.error(ExceptionUtils.getFullStackTrace(e));
return RespData.error(e.getMessage());
}
}
/**
* 船运入库导入检查
*/
@RequestMapping("/shippingPutInStorageCheck")
@ResponseBody
public RespData shippingPutInStorageCheck(MultipartFile file) {
try {
List<String> errorList = importService.shippingPutInStorageCheck(file);
return RespData.success(errorList);
} catch (Exception e) {
logger.error(ExceptionUtils.getFullStackTrace(e));
return RespData.error(e.getMessage());
}
}
/**
* 汽运入库导入检查
*/
@RequestMapping("/carPutInStorageCheck")
@ResponseBody
public RespData carPutInStorageCheck(MultipartFile file) {
try {
List<String> errorList = importService.carPutInStorageCheck(file);
return RespData.success(errorList);
} catch (Exception e) {
logger.error(ExceptionUtils.getFullStackTrace(e));
return RespData.error(e.getMessage());
}
}
/**
* 汽运入库导入
*/
@RequestMapping("/carPutInStorageUpload")
@ResponseBody
public RespData carPutInStorageUpload(MultipartFile file) {
try {
List<String> errorList = importService.carPutInStorageUpload(file);
return RespData.success(errorList);
} catch (RuntimeException e) {
logger.error(ExceptionUtils.getFullStackTrace(e));
return RespData.error(e.getMessage());
} catch (Exception e) {
logger.error(ExceptionUtils.getFullStackTrace(e));
return RespData.error("导入失败");
}
}
}

View File

@@ -0,0 +1,46 @@
package com.vverp.controller.admin;
import cn.hutool.core.bean.BeanUtil;
import com.vverp.entity.Information;
import com.vverp.moli.util.RespData;
import com.vverp.service.InformationService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.Date;
/**
* @author dealsky
* @date 2020/1/20 2:09 下午
*/
@Controller("adminInformationController")
@RequestMapping("/admin/information")
public class InformationController extends BaseController {
@Resource
private InformationService informationService;
@RequestMapping(value = "/{title}")
public String about(ModelMap modelMap, @PathVariable String title, String name) {
modelMap.addAttribute("information", informationService.findSingle());
modelMap.addAttribute("time", new Date().getTime());
modelMap.addAttribute("title", title);
modelMap.addAttribute("name", name);
return "/information/index";
}
@RequestMapping(value = "/save")
@ResponseBody
public RespData save(String title, String content) {
Information information = informationService.findSingle();
return respDataWithHandle(() -> {
BeanUtil.setFieldValue(information, title, content);
informationService.update(information);
});
}
}

View File

@@ -0,0 +1,55 @@
package com.vverp.controller.admin;
import com.vverp.util.DateUtil;
import com.vverp.dto.LogQuery;
import com.vverp.entity.Log;
import com.vverp.moli.util.Pageable;
import com.vverp.service.LogService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.annotation.Resource;
import java.util.Calendar;
import java.util.Date;
@Controller
@RequestMapping(value = "/admin/log")
public class LogController extends BaseController {
@Resource
private LogService logService;
@RequestMapping(value = "/list")
public String list(Pageable pageable, ModelMap modelMap, LogQuery query) {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH, -3);
if (query.getCreateDateStart() == null) {
query.setCreateDateStart(DateUtil.beginOfMonth(calendar.getTime()).toJdkDate());
}
if (query.getCreateDateEnd() == null) {
query.setCreateDateEnd(DateUtil.endOfMonth(new Date()).toJdkDate());
}
query.setCreateDateStart(DateUtil.beginOfDay(query.getCreateDateStart()).toJdkDate());
query.setCreateDateEnd(DateUtil.endOfDay(query.getCreateDateEnd()).toJdkDate());
modelMap.addAttribute("page", logService.findPage(pageable, query));
modelMap.addAttribute("query", query);
return "/log/list";
}
@RequestMapping(value = "/view", method = RequestMethod.GET)
public String view(Long id, ModelMap modelMap) {
Log log = logService.find(id);
modelMap.addAttribute("log", log);
return "/log/view";
}
@RequestMapping(value = "/dialogList")
public String adminLog(Pageable pageable, ModelMap modelMap) {
modelMap.addAttribute("page", logService.findPage(pageable));
return "/common/dialog/adminLog";
}
}

View File

@@ -0,0 +1,130 @@
package com.vverp.controller.admin;
import com.vverp.base.Setting;
import com.vverp.entity.*;
import com.vverp.moli.util.Message;
import com.vverp.service.*;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.web.filter.authc.FormAuthenticationFilter;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@Controller
@RequestMapping("/admin")
public class LoginController {
@Resource
private AdminService adminService;
@Resource
private MenuService menuService;
@Resource
private SystemSettingService systemSettingService;
@Resource
private ExtraFieldService extraFieldService;
@Resource
private ProgressService progressService;
@Resource
private PurchaseApplyOrderService purchaseApplyOrderService;
@Resource
private RoleService roleService;
@PostConstruct
public void init() {
purchaseApplyOrderService.init();
roleService.init();
}
@RequestMapping("/login")
public String login(ModelMap model, HttpServletRequest request, HttpSession session) {
if (adminService.isAuthenticated()) {
setModelAndSession(model, session);
return Setting.getData().getHomeUrl();
}
String failureMessage = null;
String loginFailure = (String) request.getAttribute(FormAuthenticationFilter.DEFAULT_ERROR_KEY_ATTRIBUTE_NAME);
if (StringUtils.isNotEmpty(loginFailure)) {
switch (loginFailure) {
case "org.apache.shiro.authc.UnknownAccountException":
failureMessage = "账号不存在";
break;
case "org.apache.shiro.authc.IncorrectCredentialsException":
failureMessage = "密码错误";
break;
case "org.apache.shiro.authc.DisabledAccountException":
failureMessage = "账号已禁用";
break;
default:
failureMessage = "登录失败";
break;
}
}
model.addAttribute("failureMessage", failureMessage);
model.addAttribute("systemSetting", systemSettingService.findSingle());
return "/login/index";
}
@RequestMapping(value = "/index")
public String index(ModelMap model, HttpSession session) {
if (adminService.isAuthenticated()) {
setModelAndSession(model, session);
return Setting.getData().getHomeUrl();
}
return "/login/index";
}
@RequestMapping(value = "/logout")
public String logout(ModelMap model) {
Subject subject = SecurityUtils.getSubject();
subject.logout();
return "redirect:/admin/index.html";
}
public void setModelAndSession(ModelMap model, HttpSession session) {
Admin admin = adminService.getCurrent();
model.addAttribute("admin", admin);
// model.addAttribute("showProgress", admin.getSupplier()==null);
model.addAttribute("showProgress", true);
// if (admin.getSupplier() != null) {
// model.addAttribute("progress", progressService.find(admin.getSupplier().getProgressId()));
// admin.setNowProgress(admin.getSupplier().getProgressId());
// adminService.update(admin);
// }else {
model.addAttribute("progress", progressService.find(admin.getNowProgress()));
// }
model.addAttribute("systemMenu", menuService.menuList());
model.addAttribute("systemSetting", systemSettingService.findSingle());
session.setAttribute("systemSetting", systemSettingService.findSingle());
session.setAttribute("eField", extraFieldService);
session.setAttribute("curAdmin", admin);
Department department = admin.getDepartment();
if (department != null) {
session.setAttribute("curDept", department);
session.setAttribute("curDeptName", department.getName());
}
Company company = admin.getCompany();
if (company != null) {
session.setAttribute("curCompany", company);
session.setAttribute("curCompanyName", company.getName());
}
}
}

View File

@@ -0,0 +1,58 @@
package com.vverp.controller.admin;
import com.vverp.dto.ewomail.EwoMailObject;
import com.vverp.entity.Admin;
import com.vverp.moli.util.RespData;
import com.vverp.service.AdminService;
import com.vverp.util.EwoMailUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
/**
* @author dealsky
* @date 2021/2/3 下午5:45
*/
@RequestMapping("admin/mail")
@Controller("adminMailController")
public class MailController {
@Resource
private AdminService adminService;
@RequestMapping("/login")
public String login(String email, String password) {
EwoMailObject ewoMailObject = EwoMailUtils.userLogin(email, password);
if (ewoMailObject.getStatus().equals("1")) {
return "redirect:" + ewoMailObject.getData().getStr("jump");
}
return null;
}
@RequestMapping("/loginAuth")
@ResponseBody
public RespData loginAuth() {
Admin admin = adminService.getCurrent();
EwoMailObject ewoMailObject = EwoMailUtils.userLogin(admin.getEwoEmail(), admin.getEmailPassword());
if (ewoMailObject.getStatus().equals("1")) {
return RespData.success(ewoMailObject.getData());
} else {
return RespData.error(ewoMailObject.getMsg());
}
}
@RequestMapping("/newMessage")
@ResponseBody
public RespData newMessage(Integer uidNext) {
Admin admin = adminService.getCurrent();
EwoMailObject ewoMailObject = EwoMailUtils.newMessage(admin.getEwoEmail(), "INBOX", uidNext);
if (ewoMailObject.getStatus().equals("1")) {
return RespData.success(ewoMailObject.getData());
} else {
return RespData.error(ewoMailObject.getMsg());
}
}
}

View File

@@ -0,0 +1,95 @@
package com.vverp.controller.admin;
import com.vverp.entity.Diameter;
import com.vverp.entity.Material;
import com.vverp.moli.util.Message;
import com.vverp.moli.util.Page;
import com.vverp.moli.util.Pageable;
import com.vverp.moli.util.RespData;
import com.vverp.service.MaterialService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
@RequestMapping("admin/material")
@Controller("adminMaterial")
public class MaterialController extends BaseController{
@Resource
private MaterialService materialService;
@RequestMapping("list")
public String list(ModelMap modelMap, Pageable pageable){
Page<Material> page = materialService.findPage(pageable);
modelMap.addAttribute("page",page);
return "material/list";
}
@RequestMapping("add")
public String add(){
return "material/add";
}
@RequestMapping("edit")
public String edit(ModelMap modelMap, Long id){
Material material = materialService.find(id);
modelMap.addAttribute("material",material);
return "material/edit";
}
@RequestMapping("save")
@ResponseBody
public RespData save(Material material){
if (materialService.findByAttribute("name",material.getName()) != null){
return RespData.error(material.getName()+"已存在");
}
materialService.save(material);
return RespData.success();
}
@RequestMapping("update")
@ResponseBody
public RespData update(Material material){
Material source = materialService.findByAttribute("name",material.getName());
if (source != null && !source.getId().equals(material.getId())){
return RespData.error(material.getName()+"已存在");
}
materialService.update(material);
return RespData.success();
}
@RequestMapping("delete")
@ResponseBody
public Message delete(Long ids){
materialService.delete(ids);
return Message.success("删除成功");
}
/**
* 导入模板
*/
@RequestMapping("/exportTemplate")
public void exportTemplate(HttpServletResponse response) {
materialService.exportTemplate(response);
}
@RequestMapping("import")
@ResponseBody
public RespData importExcel(MultipartFile file) {
try {
materialService.importExcel(file);
return RespData.success();
} catch (RuntimeException e) {
return RespData.error(e.getMessage());
} catch (Exception e) {
return RespData.error("导入失败");
}
}
}

View File

@@ -0,0 +1,952 @@
package com.vverp.controller.admin;
import com.vverp.base.exception.ImportExcelException;
import com.vverp.dto.CompanyQuery;
import com.vverp.dto.MaterialOrderStockTypeCountSumDto;
import com.vverp.dto.OrderQuery;
import com.vverp.entity.*;
import com.vverp.enums.OrderCategory;
import com.vverp.moli.util.Message;
import com.vverp.moli.util.Page;
import com.vverp.moli.util.Pageable;
import com.vverp.moli.util.RespData;
import com.vverp.service.*;
import com.vverp.util.ExcelImportErrorUtil;
import org.apache.commons.lang.BooleanUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.util.*;
/**
* @author dealsky
* @date 2020-03-25 16:50
*/
@Controller
@RequestMapping("/admin/materialOrder")
public class MaterialOrderController extends BaseController {
@Resource
private MaterialOrderService materialOrderService;
@Resource
private PurchaseStockService purchaseStockService;
@Resource
private SupplierService supplierService;
@Resource
private OrderTool orderTool;
@Resource
private MaterialOrderItemService materialOrderItemService;
@Resource
private SystemSettingService systemSettingService;
@Resource
private DepartmentService departmentService;
@Resource
private AdminService adminService;
@Resource
private ProductService productService;
@Resource
private MaterialOrderItemPriceService materialOrderItemPriceService;
@Resource
private ExtraFieldService extraFieldService;
@Resource
private ProductTypeService productTypeService;
@Resource
private FlowSnService flowSnService;
@Resource
private MaterialOrderStageService materialOrderStageService;
@Resource
private PurchaseApplyOrderService purchaseApplyOrderService;
@Resource
private ProgressService progressService;
@Resource
private SupplierProductService supplierProductService;
@RequestMapping("/list")
public String list(ModelMap modelMap, Pageable pageable, OrderQuery orderQuery,String pageType,Long progressId) {
Admin admin = adminService.getCurrent();
orderQuery.setProgressId(progressId == null?admin.getNowProgress():progressId);
modelMap.addAttribute("progressId",progressId);
modelMap.addAttribute("progressList",progressService.findAll());
if (admin.getNowProgress() == null) {
modelMap.addAttribute("company",true);
}else {
modelMap.addAttribute("company",false);
}
orderQuery.setVisibleCompanyIdsStr(adminService.getCurrent().getVisibleCompanyIdsStr());
orderQuery.setVisibleDepartmentIdsStr(adminService.getCurrent().getVisibleDepartmentIdsStr());
orderTool.listCommonAttr(modelMap, pageable, orderQuery, MaterialOrder.class, materialOrderService, materialOrderItemService);
// modelMap.addAttribute("ownerList", supplierService.findAll());
// modelMap.addAttribute("contractTypes", ContractType.values());
// modelMap.addAttribute("contractType", orderQuery.getContractType());
modelMap.addAttribute("productList", productService.findAll());
modelMap.addAttribute("type", orderQuery.getMaterialType());
modelMap.addAttribute("pageType",pageType);
// modelMap.addAttribute("adminId",admin.getId());
Page<MaterialOrder> page = (Page<MaterialOrder>) modelMap.get("page");
Map<Long,String> map = new HashMap<>();
for (MaterialOrder materialOrder : page.getContent()){
MaterialOrderStockTypeCountSumDto countDto = materialOrderItemService.countStockTypeByVersionNum(materialOrder.getVersionNum(), materialOrder.getId());
Long nowCount = countDto.getTotalCount();
Long allCount = countDto.getAllCount();
if (allCount.equals(nowCount)){
map.put(materialOrder.getId(),"已订货");
}else {
if (allCount>0){
map.put(materialOrder.getId(),"部分订货");
continue;
}
Long noneCount = countDto.getNoneCount();
if (noneCount < nowCount){
map.put(materialOrder.getId(),"部分订货");
}else {
map.put(materialOrder.getId(),"未订货");
}
}
}
modelMap.addAttribute("map",map);
return "/materialOrder/" + orderQuery.getMaterialType().name() + "/list";
}
@RequestMapping("/add")
public String add(ModelMap modelMap, MaterialOrder.Type type) {
Admin admin = adminService.getCurrent();
orderTool.addCommonAttr(modelMap, OrderCategory.purchase);
modelMap.addAttribute("type", type);
modelMap.addAttribute("progressId", admin.getNowProgress());
if (type.equals(MaterialOrder.Type.device)) {
modelMap.addAttribute("productList", productService.findByType(Product.Type.device));
} else {
modelMap.addAttribute("productList", productService.findByType(Product.Type.conduit));
}
return "/materialOrder/" + type.name() + "/add";
}
@RequestMapping("/view")
public String view(ModelMap modelMap, Long id, Integer nowVersion, Integer oldVersion, Boolean showDifferent, String key, String value) {
modelMap.addAttribute("key",key==null?" ":key);
modelMap.addAttribute("value",value);
MaterialOrder materialOrder = materialOrderService.find(id);
if (nowVersion == null) {
nowVersion = materialOrder.getVersionNum();
}
List<MaterialOrderItem> itemList = materialOrderItemService.findByVersionNum(materialOrder.getVersionNum(), id);
materialOrder.setMaterialOrderItemList(itemList);
// List<MaterialOrderItem> itemList = materialOrderItemService.findByVersionNum(nowVersion, id);
// Map<Integer, Object> map = new HashMap<>();
// if (showDifferent != null && showDifferent) {
// List<MaterialOrderItem> oldList = materialOrderItemService.findByVersionNum(oldVersion, id);
// for (MaterialOrderItem orderItem : oldList) {
// map.put(orderItem.getInd(), orderItem);
// }
// }
// modelMap.addAttribute("map", map);
// if (itemList.size() > 20) {
//// materialOrder.setMaterialOrderItemList(itemList);
// materialOrder.setMaterialOrderItemList(itemList.subList(0, 20));
// } else {
// materialOrder.setMaterialOrderItemList(itemList);
// }
// materialOrder.setMaterialOrderItemList(itemList);
List<Integer> versionList = new ArrayList<>();
List<Integer> allVersionList = new ArrayList<>();
for (Integer i = nowVersion; i >= 0; i--) {
versionList.add(i);
}
for (Integer i = materialOrder.getVersionNum(); i >= 0; i--) {
allVersionList.add(i);
}
Admin admin = adminService.getCurrent();
List<AdminPurchase> adminPurchaseList = admin.getAdminPurchaseList();
List<Long> showList = new ArrayList<>();
for (AdminPurchase adminPurchase : adminPurchaseList){
for (AdminPurchaseProductType adminPurchaseProductType : adminPurchase.getAdminPurchaseProductTypeList()) {
showList.add(adminPurchaseProductType.getProductType().getId());
}
// showList.add(adminPurchase.getProductType().getId());
}
CompanyQuery companyQuery = new CompanyQuery();
companyQuery.setProgressId(adminService.getCurrent().getNowProgress());
modelMap.addAttribute("supplierList", supplierService.findList(companyQuery));
modelMap.addAttribute("versionList", versionList);
modelMap.addAttribute("allVersionList", allVersionList);
modelMap.addAttribute("oldVersion", oldVersion);
modelMap.addAttribute("nowVersion", nowVersion);
modelMap.addAttribute("materialOrder", materialOrder);
modelMap.addAttribute("type", materialOrder.getType());
modelMap.addAttribute("showDifferent", BooleanUtils.isTrue(showDifferent));
modelMap.addAttribute("adminPurchaseList",showList);
return "/materialOrder/" + materialOrder.getType().name() + "/view";
}
//评标进的详情页,显示数据不同
@RequestMapping("/bidView")
public String bidView(ModelMap modelMap, Long id, Integer nowVersion, Integer oldVersion, Boolean showDifferent, String key, String value) {
modelMap.addAttribute("key",key==null?" ":key);
modelMap.addAttribute("value",value);
MaterialOrder materialOrder = materialOrderService.find(id);
if (nowVersion == null) {
nowVersion = materialOrder.getVersionNum();
}
List<MaterialOrderItem> itemList = materialOrderItemService.findByVersionNum(materialOrder.getVersionNum(), id);
materialOrder.setMaterialOrderItemList(itemList);
// List<MaterialOrderItem> itemList = materialOrderItemService.findByVersionNum(nowVersion, id);
// Map<Integer, Object> map = new HashMap<>();
// if (showDifferent != null && showDifferent) {
// List<MaterialOrderItem> oldList = materialOrderItemService.findByVersionNum(oldVersion, id);
// for (MaterialOrderItem orderItem : oldList) {
// map.put(orderItem.getInd(), orderItem);
// }
// }
// modelMap.addAttribute("map", map);
// if (itemList.size() > 20) {
//// materialOrder.setMaterialOrderItemList(itemList);
// materialOrder.setMaterialOrderItemList(itemList.subList(0, 20));
// } else {
// materialOrder.setMaterialOrderItemList(itemList);
// }
// materialOrder.setMaterialOrderItemList(itemList);
List<Integer> versionList = new ArrayList<>();
List<Integer> allVersionList = new ArrayList<>();
for (Integer i = nowVersion; i >= 0; i--) {
versionList.add(i);
}
for (Integer i = materialOrder.getVersionNum(); i >= 0; i--) {
allVersionList.add(i);
}
Admin admin = adminService.getCurrent();
List<AdminPurchase> adminPurchaseList = admin.getAdminPurchaseList();
List<Long> showList = new ArrayList<>();
for (AdminPurchase adminPurchase : adminPurchaseList){
for (AdminPurchaseProductType adminPurchaseProductType : adminPurchase.getAdminPurchaseProductTypeList()) {
showList.add(adminPurchaseProductType.getProductType().getId());
}
// showList.add(adminPurchase.getProductType().getId());
}
CompanyQuery companyQuery = new CompanyQuery();
companyQuery.setProgressId(adminService.getCurrent().getNowProgress());
modelMap.addAttribute("supplierList", supplierService.findList(companyQuery));
modelMap.addAttribute("versionList", versionList);
modelMap.addAttribute("allVersionList", allVersionList);
modelMap.addAttribute("oldVersion", oldVersion);
modelMap.addAttribute("nowVersion", nowVersion);
modelMap.addAttribute("materialOrder", materialOrder);
modelMap.addAttribute("type", materialOrder.getType());
modelMap.addAttribute("showDifferent", BooleanUtils.isTrue(showDifferent));
modelMap.addAttribute("adminPurchaseList",showList);
return "/materialOrder/" + materialOrder.getType().name() + "/bidView";
}
@RequestMapping("/edit")
public String edit(ModelMap modelMap, Long id) {
orderTool.addCommonAttr(modelMap, OrderCategory.purchase);
MaterialOrder materialOrder = materialOrderService.find(id);
List<MaterialOrderItem> itemList = materialOrderItemService.findByVersionNum(materialOrder.getVersionNum(), id);
if (itemList.size() > 20) {
// materialOrder.setMaterialOrderItemList(itemList);
materialOrder.setMaterialOrderItemList(itemList.subList(0, 20));
} else {
materialOrder.setMaterialOrderItemList(itemList);
}
modelMap.addAttribute("materialOrder", materialOrder);
modelMap.addAttribute("type", materialOrder.getType());
if (materialOrder.getType().equals(MaterialOrder.Type.device)) {
modelMap.addAttribute("productList", productService.findByType(Product.Type.device));
} else {
modelMap.addAttribute("productList", productService.findByType(Product.Type.conduit));
}
return "/materialOrder/" + materialOrder.getType().name() + "/edit";
}
@RequestMapping("/save")
@ResponseBody
public RespData save(MaterialOrder materialOrder,Long progressId) {
try {
materialOrder.setVersionNum(0);
Progress progress = progressService.find(progressId);
if (progress != null){
materialOrder.setProgressCode(progress.getCode());
materialOrder.setProgressName(progress.getName());
}else {
materialOrder.setProgressName("公司");
}
materialOrderService.saveMaterialOrder(materialOrder);
return RespData.success("保存成功");
} catch (Exception e) {
e.printStackTrace();
return RespData.error(e.getMessage());
}
}
@RequestMapping("/update")
@ResponseBody
public RespData update(MaterialOrder materialOrder) {
try {
materialOrderService.updateMaterialOrder(materialOrder);
return RespData.success("保存成功");
} catch (Exception e) {
e.printStackTrace();
return RespData.error(e.getMessage());
}
}
@RequestMapping("/updateDevice")
@ResponseBody
public RespData updateDevice(MaterialOrder materialOrder) {
try {
materialOrderService.updateDevice(materialOrder);
return RespData.success("保存成功");
} catch (Exception e) {
e.printStackTrace();
return RespData.error(e.getMessage());
}
}
@RequestMapping("/delete")
@ResponseBody
public Message delete(Long[] ids) {
materialOrderService.deleteEntity(ids);
return SUCCESS;
}
// @RequestMapping("/exportSupplier")
// public void exportSupplier(HttpServletResponse response, Long id) throws Exception {
// materialOrderService.exportSupplier(response, id);
// }
@RequestMapping("dialog/addPrice")
public String dialogAddPrice(Long id, ModelMap modelMap) {
modelMap.addAttribute("id", id);
return "materialOrder/dialog/addPrice";
}
@RequestMapping("addPrice")
public String addPrice(Long id, ModelMap modelMap) {
modelMap.addAttribute("id", id);
return "materialOrder/addPrice";
}
@RequestMapping("dialog/priceView")
public String dialogPriceView(Long id, ModelMap modelMap) {
MaterialOrderItem item = materialOrderItemService.find(id);
List<MaterialOrderItemPrice> list = new ArrayList<>();
List<MaterialOrderItemPrice> allList = item.getMaterialOrderItemPriceList();
for (MaterialOrderItemPrice itemPrice : allList) {
if (item.getSupplierIds().contains(itemPrice.getSupplierId())) {
list.add(itemPrice);
}
}
modelMap.addAttribute("list", list);
return "materialOrder/dialog/priceView";
}
/**
* 导入报价单
*/
@RequestMapping(value = "/uploadExcel", method = RequestMethod.POST)
@ResponseBody
public RespData uploadExcel(MultipartFile file) {
if (file == null) {
return RespData.error("文件为空");
}
//获得文件名
String fileName = file.getOriginalFilename();
//判断文件是否是excel文件
if (!fileName.endsWith("xls") && !fileName.endsWith("xlsx")) {
if (!fileName.endsWith("zip")) {
return RespData.error("请导入excel或者zip文件");
}else {
materialOrderItemPriceService.loadZip(file);
return RespData.success("导入成功");
}
}else {
try {
materialOrderItemPriceService.ExcelSendData(file);
return RespData.success("导入成功");
} catch (Exception e) {
e.printStackTrace();
return RespData.error(e.getMessage());
}
}
}
@RequestMapping("confirmSupplier")
@ResponseBody
public RespData confirmSupplier(Long id) {
materialOrderItemPriceService.confirmSupplier(id);
return RespData.success();
}
@RequestMapping("dialog/addFile")
public String dialogAddFile(ModelMap modelMap) {
Admin admin = adminService.getCurrent();
modelMap.addAttribute("adminId", admin.getId());
modelMap.addAttribute("stageList",materialOrderStageService.findListByAttribute("progressId",admin.getNowProgress()));
return "materialOrder/dialog/addFile";
}
@RequestMapping("dialog/addDeviceFile")
public String dialogAddDeviceFile(ModelMap modelMap) {
Admin admin = adminService.getCurrent();
modelMap.addAttribute("adminId", admin.getId());
modelMap.addAttribute("stageList",materialOrderStageService.findListByAttribute("progressId",admin.getNowProgress()));
return "materialOrder/dialog/addDeviceFile";
}
@RequestMapping("dialog/updateFile")
public String dialogAddFile(ModelMap modelMap, Long orderId) {
Admin admin = adminService.getCurrent();
// MaterialOrder materialOrder = materialOrderService.find(orderId);
modelMap.addAttribute("adminId", admin.getId());
modelMap.addAttribute("orderId", orderId);
// modelMap.addAttribute("stage", materialOrder.getStage());
modelMap.addAttribute("stageList",materialOrderStageService.findAll());
return "materialOrder/dialog/updateFile";
}
/**
* 导入明细表页面中 根据前缀和阶段找以往阶段的料单
*/
@RequestMapping(value = "/findPrevStageListDialog")
public String findPrevStageListDialog(ModelMap modelMap, Long adminId, String preTitle, Long stage) {
modelMap.addAttribute("materialOrderList", materialOrderService.findPrevStageList(adminId, preTitle, stage));
return "materialOrder/dialog/findPrevStageListDialog";
}
/**
* 导入明细表
*/
@RequestMapping(value = "/uploadOrderExcel")
@ResponseBody
public RespData uploadOrderExcel(MultipartFile file, Long adminId, String preTitle, Integer flowNum, String code, Long orderId, Long stage,String memo,String upReason,String name) {
if (orderId == null) {
if (file == null) {
return RespData.error("文件为空");
}
if (preTitle == null) {
return RespData.error("前缀不能为空");
}
if (flowNum == null) {
return RespData.error("流水号不能为空");
}
if (stage == null) {
return RespData.error("阶段不能为空");
}
}
//获得文件名
String fileName = file.getOriginalFilename();
//判断文件是否是excel文件
if (!fileName.endsWith("xls") && !fileName.endsWith("xlsx")) {
return RespData.error("不是excel文件");
}
try {
System.out.println("开始导入文件");
if (orderId == null) {
Integer specialNum = materialOrderService.saveFile(file, adminId, preTitle, flowNum, code, stage,memo,name);
if (specialNum >0){
return RespData.warn("导入成功");
}
} else {
materialOrderService.updateFile2(file, adminId, orderId,memo,upReason);
}
return RespData.success("导入成功");
} catch (Exception e) {
if (e instanceof ImportExcelException) {
return ((ImportExcelException) e).getRespData();
}
e.printStackTrace();
return RespData.error(e.getMessage());
}
}
@RequestMapping("uploadResult")
public String uploadResult(ModelMap modelMap){
return "materialOrder/dialog/uploadResult";
}
@RequestMapping("exportSpecial")
public void exportSpecial(HttpServletResponse response) {
try {
materialOrderService.exportSpecial(response);
} catch (Exception e) {
e.printStackTrace();
}
}
@RequestMapping("uploadResult2")
public String uploadResult(ModelMap modelMap,Integer successNum, Integer failNum, String importErrorExcel){
modelMap.addAttribute("successNum",successNum);
modelMap.addAttribute("failNum",failNum);
modelMap.addAttribute("importErrorExcel",importErrorExcel);
return "materialOrder/dialog/uploadResult2";
}
@RequestMapping("exportNotFund")
public void exportNotFund(String importErrorExcel, HttpServletResponse response) {
try (ServletOutputStream outputStream = response.getOutputStream()) {
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("料单导入失败"+importErrorExcel,"UTF8"));
ExcelImportErrorUtil.materialOrderGetFile(importErrorExcel, outputStream);
} catch (Exception e) {
e.printStackTrace();
}
}
@RequestMapping(value = "/uploadDeviceExcel")
@ResponseBody
public RespData uploadDeviceExcel(MultipartFile file, Long adminId, String preTitle, Integer flowNum, String code, Long orderId,Long stage,String name) {
if (file == null) {
return RespData.error("文件为空");
}
if (preTitle == null){
return RespData.error("前缀不能为空");
}
if (flowNum == null){
return RespData.error("流水号不能为空");
}
if (stage == null){
return RespData.error("阶段不能为空");
}
//获得文件名
String fileName = file.getOriginalFilename();
//判断文件是否是excel文件
if (!fileName.endsWith("xls") && !fileName.endsWith("xlsx")) {
return RespData.error("不是excel文件");
}
try {
System.out.println("开始导入文件");
if (orderId == null) {
materialOrderService.saveDeviceFile(file, adminId, preTitle, flowNum, code, stage,name);
} else {
// materialOrderService.updateDeviceFile(file, adminId,orderId,stage);
}
return RespData.success("导入成功");
} catch (Exception e) {
e.printStackTrace();
return RespData.error(e.getMessage());
}
}
@RequestMapping("dialog/selectSupplier")
public String dialogSelectSupplier(Long id, ModelMap modelMap,Long[] ids) {
String idStr = "";
if (ids != null) {
for (Long idx : ids) {
if (idx != null) {
idStr = idStr + "" + idx + ";";
}
}
}
Admin admin = adminService.getCurrent();
modelMap.addAttribute("id", id);
modelMap.addAttribute("ids", idStr);
modelMap.addAttribute("progressId", admin.getNowProgress());
return "materialOrder/dialog/selectSupplier";
}
@RequestMapping("selectSupplierIds")
@ResponseBody
public RespData selectSupplierIds(Long id, Integer number, Long progressId,String ids) {
try {
materialOrderService.selectSupplierIds(id, number, progressId,ids);
} catch (Exception e) {
e.printStackTrace();
return RespData.error(e.getMessage());
}
return RespData.success("筛选成功");
}
/** 确认供应商列表 */
@RequestMapping("batchConfirmSupplierList")
@ResponseBody
public RespData batchConfirmSupplierList(Long id) {
try {
materialOrderItemService.batchConfirmSupplierList(id);
} catch (Exception e) {
e.printStackTrace();
return RespData.error(e.getMessage());
}
return RespData.success("success");
}
@RequestMapping("confirmSupplierList")
@ResponseBody
public RespData confirmSupplierList(Long ids) {
try {
materialOrderItemService.confirmSupplierList(ids);
} catch (Exception e) {
e.printStackTrace();
return RespData.error(e.getMessage());
}
return RespData.success("success");
}
@RequestMapping("dialog/changeSupplier")
public String dialogChangeSupplier(Long id, ModelMap modelMap) {
MaterialOrderItem materialOrderItem = materialOrderItemService.find(id);
Admin admin = adminService.getCurrent();
CompanyQuery companyQuery = new CompanyQuery();
companyQuery.setProgressId(admin.getNowProgress());
List<Supplier> supplierList = supplierService.findList(companyQuery);
List<Supplier> resultList = new ArrayList<>();
for (Supplier supplier : supplierList){
for (SupplierProduct supplierProduct : supplier.getSupplierProductList()){
if (supplierProductService.containProduct(supplierProduct,materialOrderItem)){
resultList.add(supplier);
break;
}
}
}
modelMap.addAttribute("id", id);
modelMap.addAttribute("supplierList", resultList);
MaterialOrderItem item = materialOrderItemService.find(id);
modelMap.addAttribute("supplierIds", item.getSupplierIds());
return "materialOrder/dialog/changeSupplier";
}
@RequestMapping("changeSupplierList")
@ResponseBody
public RespData changeSupplierList(MaterialOrderItem item) {
try {
materialOrderService.changeSupplierList(item);
} catch (Exception e) {
e.printStackTrace();
return RespData.error(e.getMessage());
}
return RespData.success("筛选成功");
}
@RequestMapping("dialog/addApplyOrder")
public String dialogAddApplyOrder(ModelMap modelMap, Long[] ids) {
Admin admin = adminService.getCurrent();
String idStr = "";
for (Long id : ids) {
if (id != null) {
idStr = idStr + "" + id + ";";
}
}
modelMap.addAttribute("ids", idStr);
modelMap.addAttribute("adminId", admin.getId());
modelMap.addAttribute("bigTypeList", productTypeService.findListByAttribute("level", 1));
modelMap.addAttribute("smallTypeList", productTypeService.findListByAttribute("level", 2));
return "materialOrder/dialog/addApplyOrder";
}
@RequestMapping("dialog/addPurchaseOrder")
public String dialogAddPurchaseOrder(ModelMap modelMap, Long[] ids,String type) {
Admin admin = adminService.getCurrent();
String idStr = "";
for (Long id : ids) {
if (id != null) {
idStr = idStr + "" + id + ";";
}
}
modelMap.addAttribute("ids", idStr);
modelMap.addAttribute("adminId", admin.getId());
modelMap.addAttribute("type", type);
return "materialOrder/dialog/addPurchaseOrder";
}
@RequestMapping("loadItem")
@ResponseBody
public RespData loadItem(Long id, Integer size) {
MaterialOrder materialOrder = materialOrderService.find(id);
List<ExtraField> extraFieldList = extraFieldService.list("materialOrderItem", materialOrder.getProgressId());
Map<String, Object> map = new HashMap<>();
for (ExtraField extraField : extraFieldList) {
map.put(extraField.getFieldName(), extraField.getAvailable());
}
List<MaterialOrderItem> itemList = materialOrderItemService.findByVersionNum(materialOrder.getVersionNum(), id);
if (itemList.size() - size > 300) {
map.put("list", itemList.subList(size, size + 300));
map.put("loadFlag", true);
return RespData.success(map);
} else {
map.put("loadFlag", false);
map.put("list", itemList.subList(size, itemList.size()));
return RespData.success(map);
}
}
@RequestMapping("loadDiffItem")
@ResponseBody
public RespData loadDiffItem(Long id, Integer nowSize, Integer nowVersion, Integer oldVersion, String productCode, String name, String areaAccount,
String unitAccount, String siteAccount, String lineAccount, String codeType,
String shortDescription, String longDescription, String gWeight, String totalWeight,
String count, String unit, String bigProductType, String smallProductType,
String diameterL, String diameterS, String wallThicknessL, String wallThicknessS,
String size, String pressureLevel, String endFace, String material,
String insulationCode, String specialRequest, String memo,String supplierNameList, String supplierName,
String price,String bigProductDes,String smallProductDes,String makeCode,String makeName,String materialType) {
MaterialOrder materialOrder = materialOrderService.find(id);
if (materialOrder == null) {
return RespData.error("料单不存在id"+id);
}
if (nowVersion == null) {
nowVersion = materialOrder.getVersionNum();
}
Boolean showDifferent = null;
if (oldVersion != null && !oldVersion.equals(nowVersion)) {
showDifferent = true;
}
List<ExtraField> extraFieldList = extraFieldService.list("materialOrderItem", materialOrder.getProgressId());
Map<String, Object> map = new HashMap<>();
for (ExtraField extraField : extraFieldList) {
map.put(extraField.getFieldName(), extraField.getAvailable());
}
// List<MaterialOrderItem> showItemList = materialOrderItemService.findByVersionNum(materialOrder.getVersionNum(), id);
// List<MaterialOrderItem> list = new ArrayList<>();
// if (showItemList.size() - nowSize > 40) {
// list = showItemList.subList(nowSize, nowSize + 40);
// map.put("loadFlag", true);
// } else {
// list = showItemList.subList(nowSize, showItemList.size());
// map.put("loadFlag", false);
// }
int pageSize = 100;
Pageable pageable = new Pageable();
pageable.setPageNumber(nowSize / pageSize + 1);
pageable.setPageSize(pageSize);
Page<MaterialOrderItem> page = materialOrderItemService.findByVersionNum(pageable, nowVersion, id);
List<MaterialOrderItem> list = page.getContent();
boolean loadFlag = (long) pageable.getPageNumber() * pageSize < page.getTotal();
// map.put("loadFlag", list.size() == pageSize);
map.put("loadFlag", loadFlag);
list = materialOrderItemService.findSelect(list, productCode, name, areaAccount,
unitAccount, siteAccount, lineAccount, codeType,
shortDescription, longDescription, gWeight, totalWeight,
count, unit, bigProductType, smallProductType,
diameterL, diameterS, wallThicknessL, wallThicknessS,
size, pressureLevel, endFace, material,
insulationCode, specialRequest, memo,supplierNameList, supplierName,
price,bigProductDes,smallProductDes,makeCode,makeName,materialType);
Map<Long, Object> diffMap = new HashMap<>();
if (showDifferent != null) {
// List<MaterialOrderItem> oldList = materialOrderItemService.findByVersionNum(oldVersion, id);
// for (MaterialOrderItem orderItem : oldList) {
// diffMap.put(orderItem.getInd(), orderItem);
// }
for (MaterialOrderItem orderItem : list) {
MaterialOrderItem oldVersionOrderItem = materialOrderItemService.findByUniKeyAndVersionNum(id, orderItem.getProductCode(), orderItem.getUnitAccount(), orderItem.getLineAccount(), oldVersion);
if (oldVersionOrderItem != null) {
// 比较
materialOrderService.loadDiffItemUpdate(diffMap, orderItem, oldVersionOrderItem);
} else {
// 新增
materialOrderService.loadDiffItemAdd(diffMap, orderItem);
}
}
if (!loadFlag) {
// 加载结束,找到新版本删除的记录加到列表后面
materialOrderService.loadDiffItemDelete(diffMap, id, nowVersion, oldVersion, list);
}
}
map.put("list", list);
map.put("diffMap", diffMap);
map.put("showDiff", BooleanUtils.isTrue(showDifferent));
return RespData.success(map);
}
@RequestMapping("printView")
public void printView(HttpServletResponse response, Long id, String productCode, String name, String areaAccount,
String unitAccount, String siteAccount, String lineAccount, String codeType,
String shortDescription, String longDescription, String gWeight, String totalWeight,
String count, String unit, String bigProductType, String smallProductType,
String diameterL, String diameterS, String wallThicknessL, String wallThicknessS,
String size, String pressureLevel, String endFace, String material,
String insulationCode, String specialRequest, String memo,String supplierIds, String supplierName,
String price,String bigProductDes,String smallProductDes,String makeCode,String makeName,String materialType) {
materialOrderService.exportView(response, id, productCode, name, areaAccount,
unitAccount, siteAccount, lineAccount, codeType,
shortDescription, longDescription, gWeight, totalWeight,
count, unit, bigProductType, smallProductType,
diameterL, diameterS, wallThicknessL, wallThicknessS,
size, pressureLevel, endFace, material,
insulationCode, specialRequest, memo,supplierIds, supplierName,
price,bigProductDes,smallProductDes,makeCode,makeName,materialType);
}
@RequestMapping("printDiff")
public void printDiff(HttpServletResponse response,Long id,Integer nowVersion,Integer oldVersion) {
materialOrderService.exportDiff2(response, id, nowVersion,oldVersion);
}
@RequestMapping("/export")
public void export(HttpServletResponse response, OrderQuery orderQuery) {
Admin admin = adminService.getCurrent();
orderQuery.setProgressId(admin.getNowProgress());
orderQuery.setVisibleCompanyIdsStr(adminService.getCurrent().getVisibleCompanyIdsStr());
orderQuery.setVisibleDepartmentIdsStr(adminService.getCurrent().getVisibleDepartmentIdsStr());
materialOrderService.export(response, orderQuery);
}
/**
* 获取编号
*/
@RequestMapping("getCode")
@ResponseBody
public RespData getCode(String preTitle, Integer flowNum, Long stage,Long progressId) {
MaterialOrderStage materialOrderStage = materialOrderStageService.find(stage);
FlowSn flowSn = flowSnService.findByType(FlowSn.Type.material,progressId);
String flowCode = "" + (flowSn.getLastValue()+1);
while (flowNum > flowCode.length()) {
flowCode = "0" + flowCode;
}
String sn = preTitle + "-" + flowCode + "-"+materialOrderStage.getCode() + "-V0";
return RespData.success(sn);
}
/**评标*/
@RequestMapping("dialog/bidEvaluation")
public String dialogBidEvaluation(Long[] ids,ModelMap modelMap){
Admin admin = adminService.getCurrent();
String idStr = "";
for (Long id : ids) {
if (id != null) {
idStr = idStr + "" + id + ";";
}
}
modelMap.addAttribute("ids", idStr);
return "materialOrder/dialog/bidEvaluation";
}
@RequestMapping("bidEvaluation")
@ResponseBody
public RespData bidEvaluation(String ids,String type){
String[] arr = ids.split(",");
List<MaterialOrderItem> materialItemIds = new ArrayList<>();
List<MaterialOrder> materialOrderList = new ArrayList<>();
List<Long> progressIdList = new ArrayList<>();
for (String idStr : arr){
if (idStr != null && !idStr.equals("")){
Long id = Long.valueOf(idStr);
MaterialOrder materialOrder = materialOrderService.find(id);
materialOrderList.add(materialOrder);
if (!progressIdList.contains(materialOrder.getProgressId())) {
progressIdList.add(materialOrder.getProgressId());
}
materialItemIds.addAll(materialOrderItemService.findByVersionNum(materialOrder.getVersionNum(),materialOrder.getId()));
}
}
materialOrderItemPriceService.selectPrice(materialItemIds,type,progressIdList);
// materialOrderItemPriceService.selectPrice2(materialItemIds,type,materialOrderList);
return RespData.success("评标完成");
}
@RequestMapping("addFile")
public String addFile(ModelMap modelMap) {
Admin admin = adminService.getCurrent();
modelMap.addAttribute("adminId", admin.getId());
modelMap.addAttribute("progressId", admin.getNowProgress());
modelMap.addAttribute("stageList",materialOrderStageService.findListByAttribute("progressId",admin.getNowProgress()));
return "materialOrder/addFile";
}
@RequestMapping("addDeviceFile")
public String addDeviceFile(ModelMap modelMap) {
Admin admin = adminService.getCurrent();
modelMap.addAttribute("adminId", admin.getId());
modelMap.addAttribute("stageList",materialOrderStageService.findListByAttribute("progressId",admin.getNowProgress()));
return "materialOrder/addDeviceFile";
}
@RequestMapping("sendMessage")
@ResponseBody
public RespData sendMessage(Long id,Long adminId,String content) {
MaterialOrder materialOrder = materialOrderService.find(id);
List<ProductType> productTypeList = new ArrayList<>();
Map<Long,ProductType> typeMap = new HashMap<>();
for (ProductType productType : productTypeService.findAll()){
if (productType.getName() != null){
typeMap.put(productType.getId(),productType);
}
}
List<MaterialOrderItem> itemList =materialOrderItemService.findByVersionNum(materialOrder.getVersionNum(),materialOrder.getId());
for (MaterialOrderItem materialOrderItem :itemList ){
ProductType productType = typeMap.get(materialOrderItem.getSmallTypeId());
if (productType == null){
productType = typeMap.get(materialOrderItem.getBigProductTypeId());
}
if (productType != null && !productTypeList.contains(productType)){
productTypeList.add(productType);
}
}
materialOrderService.sendMessage(productTypeList,adminId,materialOrder,content);
return RespData.success();
}
@RequestMapping("priceList")
public String priceList(ModelMap modelMap,Pageable pageable,Long supplierId,String bigType,String smallType,String orderSn){
Admin admin = adminService.getCurrent();
Long progressId = admin.getNowProgress();
for (Supplier supplier : admin.getSupplierList()){
if (progressId == null){
if (supplier.getProgressId() == null){
supplierId = supplier.getId();
}
}else {
if (progressId.equals(supplier.getProgressId())){
supplierId = supplier.getId();
}
}
}
// if (admin.getSupplier() != null){
// supplierId = admin.getSupplier().getId();
// }
Page<MaterialOrderItemPrice> page = materialOrderItemPriceService.findPageView(pageable,supplierId,bigType,smallType,orderSn,progressId);
modelMap.addAttribute("page",page);
return "materialOrder/priceList";
}
/** 导出评标不合理价格 */
@RequestMapping("/exportUnreasonableBidPrice")
public void exportUnreasonableBidPrice(HttpServletResponse response, Long... ids)throws Exception {
materialOrderService.exportUnreasonableBidPrice2(response, ids);
}
/**批量删除请购单*/
@RequestMapping("deleteApplyOrder")
@ResponseBody
public Message deleteApplyOrder(Long ids){
purchaseApplyOrderService.deleteByMaterial(ids);
return Message.success("删除成功");
}
/**编辑邮件内容*/
@RequestMapping("dialog/editMessage")
public String dialogEditMessage(Long id,ModelMap modelMap){
modelMap.addAttribute("id",id);
Admin admin = adminService.getCurrent();
modelMap.addAttribute("adminId",admin.getId());
return "materialOrder/dialog/editMessage";
}
}

View File

@@ -0,0 +1,126 @@
package com.vverp.controller.admin;
import com.vverp.entity.Admin;
import com.vverp.entity.MaterialOrderStage;
import com.vverp.entity.Progress;
import com.vverp.moli.util.Message;
import com.vverp.moli.util.Page;
import com.vverp.moli.util.Pageable;
import com.vverp.moli.util.RespData;
import com.vverp.service.AdminService;
import com.vverp.service.MaterialOrderStageService;
import com.vverp.service.ProgressService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
@RequestMapping("admin/materialOrderStage")
@Controller("adminMaterialOrderStage")
public class MaterialOrderStageController extends BaseController{
@Resource
private MaterialOrderStageService materialOrderStageService;
@Resource
private AdminService adminService;
@Resource
private ProgressService progressService;
@RequestMapping("list")
public String list(ModelMap modelMap, Pageable pageable){
Admin admin = adminService.getCurrent();
Page<MaterialOrderStage> page = materialOrderStageService.findPageView(pageable,admin.getNowProgress());
modelMap.addAttribute("page",page);
return "materialOrderStage/list";
}
@RequestMapping("add")
public String add(ModelMap modelMap){
MaterialOrderStage sourceStage = materialOrderStageService.findByLastStage(adminService.getCurrent().getNowProgress());
// modelMap.addAttribute("progressList",progressService.findAll());
modelMap.addAttribute("stage",sourceStage == null?1:sourceStage.getStageNum()+1);
modelMap.addAttribute("progressId",adminService.getCurrent().getNowProgress());
return "materialOrderStage/add";
}
@RequestMapping("edit")
public String edit(ModelMap modelMap,Long id){
MaterialOrderStage materialOrderStage = materialOrderStageService.find(id);
// modelMap.addAttribute("progressList",progressService.findAll());
modelMap.addAttribute("materialOrderStage",materialOrderStage);
return "materialOrderStage/edit";
}
@RequestMapping("save")
@ResponseBody
public Message save(MaterialOrderStage materialOrderStage){
// if (materialOrderStage.getProgressId() == null){
// return Message.error("当前项目不能为公司");
// }
if (materialOrderStage.getStageNum() == null){
return Message.error("阶段等级不能为空");
}
if (materialOrderStage.getName() == null){
return Message.error("名称不能为空");
}
if (materialOrderStage.getCode() == null){
return Message.error("代码不能为空");
}
Admin admin = adminService.getCurrent();
MaterialOrderStage sourceStage = materialOrderStageService.findByStageNum(materialOrderStage.getStageNum(),admin.getNowProgress());
if (sourceStage != null){
return Message.error("已存在阶段等级"+materialOrderStage.getStageNum());
}
Integer preStageNum = materialOrderStage.getStageNum()-1;
if (preStageNum >0) {
MaterialOrderStage preStage = materialOrderStageService.findByStageNum(preStageNum,admin.getNowProgress());
if (preStage == null){
return Message.error(preStageNum+"阶段不存在");
}
}
materialOrderStageService.save(materialOrderStage);
return Message.success("保存成功");
}
@RequestMapping("update")
@ResponseBody
public Message update(MaterialOrderStage materialOrderStage){
// if (materialOrderStage.getProgressId() == null){
// return Message.error("当前项目不能为公司");
// }
if (materialOrderStage.getName() == null){
return Message.error("名称不能为空");
}
if (materialOrderStage.getCode() == null){
return Message.error("代码不能为空");
}
if (materialOrderStage.getStageNum() == null){
return Message.error("阶段等级不能为空");
}
Admin admin = adminService.getCurrent();
MaterialOrderStage sourceStage = materialOrderStageService.findByStageNum(materialOrderStage.getStageNum(),admin.getNowProgress());
if (sourceStage != null && !sourceStage.getId().equals(materialOrderStage.getId())){
return Message.error("已存在阶段等级"+materialOrderStage.getStageNum());
}
Integer preStageNum = materialOrderStage.getStageNum()-1;
if (preStageNum >0) {
MaterialOrderStage preStage = materialOrderStageService.findByStageNum(preStageNum,admin.getNowProgress());
if (preStage == null){
return Message.error(preStageNum+"阶段不存在");
}
}
materialOrderStageService.update(materialOrderStage,"progressId");
return Message.success("保存成功");
}
@RequestMapping("delete")
@ResponseBody
public Message delete(Long ids){
materialOrderStageService.delete(ids);
return Message.success("删除成功");
}
}

View File

@@ -0,0 +1,108 @@
package com.vverp.controller.admin;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.vverp.entity.Menu;
import com.vverp.moli.util.Order;
import com.vverp.moli.util.Pageable;
import com.vverp.moli.util.RespData;
import com.vverp.service.MenuService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping("/admin/menu")
public class MenuController extends BaseController {
@Resource
private MenuService menuService;
@RequestMapping("/index")
public String index() {
return "/t-menu/index";
}
@RequestMapping("/dialog/add")
public String dialogAdd(ModelMap modelMap, String level, String parentId) {
modelMap.put("level", level);
modelMap.put("parentId", parentId);
return "/t-menu/dialog/add";
}
@RequestMapping("/dialog/edit")
public String dialogEdit(ModelMap modelMap, Long id) {
modelMap.put("menu", menuService.find(id));
return "/t-menu/dialog/edit";
}
@RequestMapping("/save")
@ResponseBody
public RespData save(Menu menu) {
if (menu.getLevel() == null) {
return RespData.error("类型不能为空");
}
if(menu.getSortFactor() == null) {
menu.setSortFactor(menuService.getMaxSortFactor(menu.getLevel(), menu.getParentId()) + 1);
}
menuService.save(menu);
return RespData.success();
}
@RequestMapping("/update")
@ResponseBody
public RespData update(Menu menu) {
menuService.updateMenu(menu);
return RespData.success();
}
@RequestMapping("/listAll")
@ResponseBody
public RespData listAll() {
Map<String, Object> map = new HashMap<>();
map.put("list", menuService.findList(null, null, Collections.singletonList(Order.asc("sortFactor"))));
return RespData.success(map);
}
@RequestMapping("/changeIndex")
@ResponseBody
public RespData changeIndex(String jsonStr) {
JSONArray jsonArray = JSONArray.parseArray(jsonStr);
for (Object item : jsonArray) {
JSONObject jsonObject = (JSONObject) item;
Long id = jsonObject.getLong("id");
Integer index = jsonObject.getInteger("index");
Menu menu = menuService.find(id);
menu.setSortFactor(index);
menuService.update(menu);
}
return RespData.success();
}
@RequestMapping("/delete")
@ResponseBody
public RespData delete(Long id) {
Menu menu = menuService.find(id);
if (menu.getLevel().equals(1)) {
List<Menu> list = menuService.findListByLevel(2, menu.getId());
list.add(menu);
for (Menu item : list) {
menuService.delete(item);
}
} else {
menuService.delete(menu);
}
return RespData.success();
}
}

View File

@@ -0,0 +1,128 @@
package com.vverp.controller.admin;
import com.vverp.util.DateUtil;
import com.vverp.entity.Admin;
import com.vverp.entity.Notice;
import com.vverp.entity.NoticeEntity;
import com.vverp.moli.util.Message;
import com.vverp.moli.util.Page;
import com.vverp.moli.util.Pageable;
import com.vverp.moli.util.RespData;
import com.vverp.service.AdminService;
import com.vverp.service.NoticeEntityService;
import com.vverp.service.NoticeService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping("/admin/notice")
public class NoticeController extends BaseController {
@Resource
private NoticeService noticeService;
@Resource
private AdminService adminService;
@Resource
private NoticeEntityService noticeEntityService;
@RequestMapping("/list")
public String list(ModelMap modelMap, Pageable pageable) {
Page<Notice> page = noticeService.findPage(pageable);
modelMap.addAttribute("page", page);
return "/notice/list";
}
@RequestMapping("/listForView")
public String listForView(ModelMap modelMap, Pageable pageable) {
Admin admin = adminService.getCurrent();
Page<NoticeEntity> page = noticeEntityService.findPage(pageable,admin);
modelMap.addAttribute("page", page);
return "/notice/listForView";
}
@RequestMapping("/add")
public String add(ModelMap modelMap) {
modelMap.addAttribute("time", System.currentTimeMillis());
return "/notice/add";
}
@RequestMapping("/save")
@ResponseBody
public Message save(Notice notice) {
try {
noticeService.saveNotice(notice);
} catch (RuntimeException e) {
return Message.error(e.getMessage());
}
return SUCCESS;
}
@RequestMapping("/edit")
public String edit(ModelMap modelMap, Long id) {
modelMap.addAttribute("notice", noticeService.find(id));
modelMap.addAttribute("time", System.currentTimeMillis());
return "/notice/edit";
}
@RequestMapping("/update")
@ResponseBody
public Message update(Notice notice) {
try {
noticeService.updateNotice(notice);
} catch (RuntimeException e) {
return Message.error(e.getMessage());
}
return SUCCESS;
}
@RequestMapping(value = "/delete", method = RequestMethod.POST)
public @ResponseBody
Message delete(Long[] ids) {
noticeService.delete(ids);
return SUCCESS;
}
@RequestMapping(value = "/dataList", method = RequestMethod.GET)
@ResponseBody
public RespData list(Pageable pageable) {
Admin admin = adminService.getCurrent();
Page<NoticeEntity> page = noticeEntityService.findPage(pageable, admin);
// Page<Notice> page = noticeService.findPage(pageable);
List<Map<String, Object>> list = new ArrayList<>();
for (NoticeEntity entity : page.getContent()) {
Map<String, Object> map = new HashMap<>();
map.put("id", entity.getId());
map.put("title", entity.getTitle());
map.put("type", Notice.Type.system);
// map.put("read", entity.getRead());
map.put("date", DateUtil.format(entity.getCreateDate(), "yyyy-MM-dd"));
list.add(map);
}
return RespData.success(new Page<>(list, page.getTotal(), page.getPageable()));
}
@RequestMapping(value = "/data", method = RequestMethod.GET)
@ResponseBody
public RespData data(Long id) {
return RespData.success(noticeEntityService.find(id));
}
@RequestMapping("getData")
@ResponseBody
public RespData getData(Long id){
return RespData.success(noticeEntityService.find(id).getContent());
}
}

View File

@@ -0,0 +1,28 @@
package com.vverp.controller.admin;
import com.vverp.service.OrderLogService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.Resource;
/**
* @author dealsky
* @date 2020/4/13 9:12 上午
*/
@Controller("adminOrderLogController")
@RequestMapping("/admin/orderLog")
public class OrderLogController extends BaseController {
@Resource
private OrderLogService orderLogService;
@RequestMapping("/list")
public String list(String sn, ModelMap modelMap) {
modelMap.addAttribute("sn", sn);
modelMap.addAttribute("list", orderLogService.findListBySn(sn));
return "/common/dialog/orderLog";
}
}

View File

@@ -0,0 +1,119 @@
package com.vverp.controller.admin;
import com.vverp.entity.BaseEntity;
import com.vverp.moli.util.RespData;
import com.vverp.util.MapUtils;
import org.bouncycastle.math.raw.Mod;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import com.vverp.entity.PaymentAccount;
import com.vverp.service.PaymentAccountService;
import com.vverp.moli.util.Page;
import com.vverp.moli.util.Pageable;
import org.springframework.ui.ModelMap;
import com.vverp.moli.util.Message;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Controller("adminPaymentAccountController")
@RequestMapping("/admin/paymentAccount")
public class PaymentAccountController extends BaseController {
@Resource
private PaymentAccountService paymentAccountService;
@RequestMapping("/list")
public String list(Pageable pageable, Date createDateStart, Date createDateEnd, String name, String account, String bankName, ModelMap modelMap) {
Page<PaymentAccount> page = paymentAccountService.findPageView(pageable, createDateStart, createDateEnd, name, account, bankName);
modelMap.addAttribute("page", page);
modelMap.addAttribute("createDateStart", createDateStart);
modelMap.addAttribute("createDateEnd", createDateEnd);
modelMap.addAttribute("name", name);
modelMap.addAttribute("account", account);
modelMap.addAttribute("bankName", bankName);
// modelMap.addAttribute("balance", balance);
return "/paymentAccount/list";
}
@RequestMapping("/add")
public String add() {
return "/paymentAccount/add";
}
@RequestMapping("/save")
@ResponseBody
public Message save(PaymentAccount paymentAccount) {
if (!isValid(paymentAccount, BaseEntity.Save.class)) {
return SUCCESS;
}
try {
paymentAccountService.save2(paymentAccount);
return SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ERROR;
}
}
@RequestMapping(value = "/edit")
public String edit(Long id, ModelMap modelMap) {
PaymentAccount paymentAccount = paymentAccountService.find(id);
modelMap.addAttribute("paymentAccount", paymentAccount);
return "/paymentAccount/edit";
}
@RequestMapping("/update")
@ResponseBody
public Message update(PaymentAccount paymentAccount) {
if (!isValid(paymentAccount, BaseEntity.Update.class)) {
return ERROR;
}
try {
paymentAccountService.update2(paymentAccount);
return SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ERROR;
}
}
@RequestMapping(value = "/delete", method = RequestMethod.POST)
@ResponseBody
public Message delete(Long ids) {
paymentAccountService.delete(ids);
return SUCCESS;
}
@RequestMapping("/updateBalance")
@ResponseBody
public RespData updateBalance(Long id, BigDecimal balance) {
PaymentAccount paymentAccount = paymentAccountService.find(id);
paymentAccount.setBalance(balance);
paymentAccountService.update(paymentAccount);
return RespData.success();
}
@RequestMapping("/dialog/balance")
public String dialogBalance(Long id, ModelMap modelMap) {
PaymentAccount paymentAccount = paymentAccountService.find(id);
modelMap.addAttribute("paymentAccount", paymentAccount);
return "/paymentAccount/dialog/balance";
}
@RequestMapping("/listAll")
@ResponseBody
public RespData listAll() {
List<PaymentAccount> paymentAccountList = paymentAccountService.findAll();
List<Map<String, Object>> list = MapUtils.beansToMapList(paymentAccountList, "name", "account", "bankName", "balance");
return RespData.success(list);
}
}

View File

@@ -0,0 +1,328 @@
package com.vverp.controller.admin;
import com.vverp.util.DateUtil;
import com.vverp.dto.OrderQuery;
import com.vverp.dto.PaymentApplyQuery;
import com.vverp.entity.*;
import com.vverp.enums.OrderStatus;
import com.vverp.enums.Reservoir;
import com.vverp.moli.util.Filter;
import com.vverp.moli.util.Message;
import com.vverp.moli.util.Pageable;
import com.vverp.moli.util.RespData;
import com.vverp.service.*;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* @author dealsky
* @date 2020/6/14 5:13 下午
*/
@Controller("adminPaymentApplyController")
@RequestMapping("/admin/paymentApply")
public class PaymentApplyController extends BaseController {
@Resource
private PaymentApplyService paymentApplyService;
@Resource
private DepartmentService departmentService;
@Resource
private CompanyService companyService;
@Resource
private AdminService adminService;
@Resource
private SupplierService supplierService;
@Resource
private PurchaseOrderService purchaseOrderService;
@RequestMapping("/create")
@ResponseBody
public RespData create(PaymentApply paymentApply) {
return respDataWithHandle(() -> paymentApplyService.create(paymentApply));
}
@RequestMapping("/createUpdate")
@ResponseBody
public RespData createUpdate(PaymentApply paymentApply) {
return respDataWithHandle(() -> paymentApplyService.createUpdate(paymentApply));
}
@RequestMapping("/selfCreate")
@ResponseBody
public RespData selfCreate(PaymentApply paymentApply) {
return respDataWithHandle(() -> paymentApplyService.selfCreate(paymentApply));
}
@RequestMapping("/selfCreateUpdate")
@ResponseBody
public RespData selfCreateUpdate(PaymentApply paymentApply) {
return respDataWithHandle(() -> paymentApplyService.selfCreateUpdate(paymentApply));
}
@RequestMapping("/dialog/add")
public String dialogAdd(ModelMap modelMap, Long id, PaymentApply.Type type, Long sourceId, PaymentApply.ReceivePayment receivePayment) {
modelMap.addAttribute("contentId", id);
modelMap.addAttribute("type", type);
modelMap.addAttribute("departmentList", departmentService.findAll());
modelMap.addAttribute("companyList", companyService.findAll());
modelMap.addAttribute("adminList", adminService.findAll());
modelMap.addAttribute("ownerList", supplierService.findAll());
modelMap.addAttribute("today", DateUtil.formatDate(new Date()));
modelMap.addAttribute("source", paymentApplyService.find(sourceId));
modelMap.addAttribute("receivePayment", receivePayment);
if (type.equals(PaymentApply.Type.purchaseOrder)) {
PurchaseOrder purchaseOrder = purchaseOrderService.find(id);
Supplier supplier = supplierService.find(purchaseOrder.getOwnerId());
modelMap.addAttribute("ownerId", purchaseOrder.getOwnerId());
modelMap.addAttribute("ownerName", purchaseOrder.getOwnerName());
modelMap.addAttribute("departmentId", purchaseOrder.getDepartmentId());
modelMap.addAttribute("departmentName", purchaseOrder.getDepartmentName());
modelMap.addAttribute("companyId", purchaseOrder.getCompanyId());
modelMap.addAttribute("companyName", purchaseOrder.getCompanyName());
modelMap.addAttribute("bankAccountList", supplier.getBankAccountList());
modelMap.addAttribute("orderSn",purchaseOrder.getSn());
modelMap.addAttribute("orderAmount",purchaseOrder.getTotalAmount());
modelMap.addAttribute("payAmount",purchaseOrder.getPaymentAmount());
modelMap.addAttribute("purchaseType",purchaseOrder.getPurchaseType());
modelMap.addAttribute("estimatedAmount",purchaseOrder.getEstimatedAmount());
}
return "/paymentApply/dialog/add";
}
@RequestMapping("/dialog/edit")
public String dialogEdit(ModelMap modelMap, Long id) {
PaymentApply paymentApply = paymentApplyService.find(id);
modelMap.addAttribute("paymentApply", paymentApply);
if (paymentApply.getType().equals(PaymentApply.Type.purchaseOrder)) {
PurchaseOrder purchaseOrder = purchaseOrderService.find(paymentApply.getContentId());
Supplier supplier = supplierService.find(purchaseOrder.getOwnerId());
modelMap.addAttribute("bankAccountList", supplier.getBankAccountList());
}
return "/paymentApply/dialog/edit";
}
@RequestMapping("/dialog/selfAdd")
public String dialogSelfAdd(ModelMap modelMap, PaymentApply.Type type, PaymentApply.ReceivePayment receivePayment, Long contentId) {
if (receivePayment == null) {
receivePayment = PaymentApply.ReceivePayment.payment;
}
modelMap.addAttribute("departmentList", departmentService.findAll());
modelMap.addAttribute("companyList", companyService.findAll());
modelMap.addAttribute("adminList", adminService.findAll());
modelMap.addAttribute("department", adminService.getCurrent().getDepartment());
modelMap.addAttribute("reservoirs", Reservoir.values());
modelMap.addAttribute("contentId", contentId);
if (type == null) {
type = PaymentApply.Type.purchaseOrder;
}
if (type.equals(PaymentApply.Type.purchaseOrder)) {
modelMap.addAttribute("ownerList", supplierService.findAll());
modelMap.addAttribute("purchaseOrderList", purchaseOrderService.findAll());
} else {
modelMap.addAttribute("ownerList", supplierService.findAll());
}
modelMap.addAttribute("today", DateUtil.formatDate(new Date()));
modelMap.addAttribute("receivePayment", receivePayment);
modelMap.addAttribute("type", type);
modelMap.addAttribute("paymentApplyTypes", PaymentApply.Type.values());
return "/paymentApply/dialog/selfAdd";
}
@RequestMapping("/dialog/selfEdit")
public String selfEdit(ModelMap modelMap, Long id) {
PaymentApply paymentApply = paymentApplyService.find(id);
modelMap.addAttribute("paymentApply", paymentApply);
modelMap.addAttribute("companyList", companyService.findAll());
if (paymentApply.getType().equals(PaymentApply.Type.purchaseOrder)) {
modelMap.addAttribute("ownerList", supplierService.findAll());
modelMap.addAttribute("bankAccountList", supplierService.find(paymentApply.getOwnerId()).getBankAccountList());
} else {
modelMap.addAttribute("ownerList", supplierService.findAll());
modelMap.addAttribute("bankAccountList", supplierService.find(paymentApply.getOwnerId()).getBankAccountList());
}
return "/paymentApply/dialog/selfEdit";
}
@RequestMapping("/list")
public String list(ModelMap modelMap, Pageable pageable, PaymentApplyQuery query) {
// query.setContractRequired(false);
// query.setApprovalFailed(false);
modelMap.addAttribute("page", paymentApplyService.findPage(pageable, query));
modelMap.addAttribute("statusList", PaymentApply.Status.values());
modelMap.addAttribute("reservoirs", Reservoir.values());
modelMap.addAttribute("companyList", companyService.findAll());
modelMap.addAttribute("query", query);
if (PaymentApply.Type.inspection.equals(query.getType())) {
OrderQuery orderQuery = new OrderQuery();
orderQuery.setCompanyId(query.getCompanyId());
orderQuery.setReservoir(query.getReservoir());
orderQuery.setStatusList(Arrays.asList(OrderStatus.approved, OrderStatus.completed));
BigDecimal totalAmount = BigDecimal.ZERO;
BigDecimal paidAmount = paymentApplyService.calcAmount(query);
BigDecimal unpaidAmount = totalAmount.subtract(paidAmount);
modelMap.addAttribute("totalAmount", totalAmount);
modelMap.addAttribute("paidAmount", paidAmount);
modelMap.addAttribute("unpaidAmount", unpaidAmount);
}
return "/paymentApply/list";
}
@RequestMapping("/dialog/list")
public String dialogList(ModelMap modelMap, PaymentApply.Type type, Long contentId, PaymentApply.ReceivePayment receivePayment) {
List<PaymentApply> list = paymentApplyService.findList(null,
Arrays.asList(
Filter.eq("type", type),
Filter.eq("contentId", contentId),
Filter.eq("approvalFailed", false),
Filter.eq("receivePayment", receivePayment)
)
, null);
modelMap.addAttribute("type", type);
modelMap.addAttribute("list", list);
modelMap.addAttribute("receivePayment", receivePayment);
return "/paymentApply/dialog/list";
}
@RequestMapping("/dialog/view")
public String dialogView(ModelMap modelMap, Long id) {
PaymentApply paymentApply = paymentApplyService.find(id);
modelMap.addAttribute("paymentApply", paymentApply);
return "/paymentApply/dialog/view";
}
@RequestMapping("/confirmPay")
@ResponseBody
public RespData confirmPay(Long id) {
PaymentApply paymentApply = paymentApplyService.find(id);
if (paymentApply.getStatus().equals(PaymentApply.Status.complete)) {
return RespData.error("已付款");
}
paymentApply.setStatus(PaymentApply.Status.complete);
paymentApplyService.update(paymentApply);
return RespData.success();
}
@RequestMapping("/approveApply")
@ResponseBody
public RespData approveApply(Long id) {
PaymentApply paymentApply = paymentApplyService.find(id);
return respDataWithHandle(() -> paymentApplyService.approveApply(paymentApply));
}
@RequestMapping("/dialog/confirm")
public String dialogConfirm(ModelMap modelMap, Long id) {
modelMap.addAttribute("paymentApply", paymentApplyService.find(id));
return "/paymentApply/dialog/confirm";
}
@RequestMapping("/doConfirm")
@ResponseBody
public RespData doConfirm(PaymentApply paymentApply) {
PaymentApply source = paymentApplyService.find(paymentApply.getId());
source.setConfirmAttachFileIds(paymentApply.getConfirmAttachFileIds());
paymentApplyService.update(source);
return RespData.success();
}
@RequestMapping(value = "/delete")
@ResponseBody
public Message delete(Long ids) {
paymentApplyService.delete(ids);
return SUCCESS;
}
/**
* 出纳确认列表
*/
@RequestMapping("/cashierConfirmList")
public String cashierConfirmList(ModelMap modelMap, Pageable pageable, PaymentApplyQuery query) {
query.setApprovalFailed(false);
query.setCashierConfirmFlag(false);
query.setReceivePayment(PaymentApply.ReceivePayment.receive);
modelMap.addAttribute("page", paymentApplyService.findPage(pageable, query));
modelMap.addAttribute("statusList", PaymentApply.Status.values());
modelMap.addAttribute("reservoirs", Reservoir.values());
modelMap.addAttribute("companyList", companyService.findAll());
modelMap.addAttribute("query", query);
return "/paymentApply/cashierConfirmList";
}
/**
* 收款确认
*/
@RequestMapping("/receiveConfirm")
@ResponseBody
public RespData receiveConfirm(Long id) {
PaymentApply paymentApply = paymentApplyService.find(id);
return respDataWithHandle(() -> paymentApplyService.receiveConfirm(paymentApply));
}
@RequestMapping("/export")
public void export(HttpServletResponse response, PaymentApplyQuery query) {
paymentApplyService.export(response,query);
}
@RequestMapping("/exportTemplate")
public void exportTemplate(HttpServletResponse response) {
paymentApplyService.exportTemplate(response);
}
@RequestMapping("dialog/addFile")
public String dialogAddFile (ModelMap modelMap){
Admin admin = adminService.getCurrent();
modelMap.addAttribute("adminId",admin.getId());
return "paymentApply/dialog/addFile";
}
/**
* 导入明细表
*/
@RequestMapping(value = "/uploadExcel")
@ResponseBody
public RespData uploadOrderExcel(MultipartFile file, Long adminId) {
if (file == null) {
return RespData.error("文件为空");
}
//获得文件名
String fileName = file.getOriginalFilename();
//判断文件是否是excel文件
if (!fileName.endsWith("xls") && !fileName.endsWith("xlsx")) {
return RespData.error("不是excel文件");
}
try {
paymentApplyService.saveFile(file, adminId);
return RespData.success("导入成功");
}catch (Exception e){
e.printStackTrace();
return RespData.error(e.getMessage());
}
}
}

View File

@@ -0,0 +1,97 @@
package com.vverp.controller.admin;
import com.vverp.entity.PaymentMethod;
import com.vverp.moli.util.Message;
import com.vverp.moli.util.Pageable;
import com.vverp.moli.util.RespData;
import com.vverp.service.PaymentMethodService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
/**
* @author dealsky
* @date 2020/4/26 11:11 上午
*/
@Controller("adminPaymentMethodController")
@RequestMapping("/admin/paymentMethod")
public class PaymentMethodController extends BaseController {
@Resource
private PaymentMethodService paymentMethodService;
@RequestMapping("/list")
public String list(ModelMap modelMap, Pageable pageable) {
modelMap.addAttribute("page", paymentMethodService.findPage(pageable));
return "/paymentMethod/list";
}
@RequestMapping("/add")
public String add() {
return "/paymentMethod/add";
}
@RequestMapping("/dialog/add")
public String dialogAdd(ModelMap modelMap, Long id) {
PaymentMethod paymentMethod = paymentMethodService.find(id);
if (paymentMethod != null) {
modelMap.addAttribute("paymentMethod", paymentMethod);
}
return "/paymentMethod/dialog/add";
}
@RequestMapping("/edit")
public String edit(ModelMap modelMap, Long id) {
PaymentMethod paymentMethod = paymentMethodService.find(id);
modelMap.addAttribute("paymentMethod", paymentMethod);
return "/paymentMethod/edit";
}
@RequestMapping("/save")
@ResponseBody
public RespData save(PaymentMethod paymentMethod) {
try {
paymentMethodService.saveEntity(paymentMethod);
return RespData.success();
} catch (RuntimeException e) {
return RespData.error(e.getMessage());
}
}
@RequestMapping("/update")
@ResponseBody
public RespData update(PaymentMethod paymentMethod) {
try {
paymentMethodService.updateEntity(paymentMethod);
return RespData.success();
} catch (RuntimeException e) {
return RespData.error(e.getMessage());
}
}
@RequestMapping("/dialogSave")
@ResponseBody
public RespData dialogSave(PaymentMethod paymentMethod) {
try {
if (paymentMethod.getId() == null) {
paymentMethodService.saveEntity(paymentMethod);
} else {
paymentMethodService.updateEntity(paymentMethod);
}
return RespData.success(paymentMethod.getId());
} catch (RuntimeException e) {
return RespData.error(e.getMessage());
}
}
@RequestMapping("/delete")
@ResponseBody
public Message delete(Long[] ids) {
paymentMethodService.delete(ids);
return SUCCESS;
}
}

View File

@@ -0,0 +1,95 @@
package com.vverp.controller.admin;
import com.vverp.entity.Diameter;
import com.vverp.entity.PressureLevel;
import com.vverp.moli.util.Message;
import com.vverp.moli.util.Page;
import com.vverp.moli.util.Pageable;
import com.vverp.moli.util.RespData;
import com.vverp.service.PressureLevelService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
@RequestMapping("admin/pressureLevel")
@Controller("adminPressureLevel")
public class PressureLevelController extends BaseController{
@Resource
private PressureLevelService pressureLevelService;
@RequestMapping("list")
public String list(ModelMap modelMap, Pageable pageable){
Page<PressureLevel> page = pressureLevelService.findPage(pageable);
modelMap.addAttribute("page",page);
return "pressureLevel/list";
}
@RequestMapping("add")
public String add(){
return "pressureLevel/add";
}
@RequestMapping("edit")
public String edit(ModelMap modelMap, Long id){
PressureLevel pressureLevel = pressureLevelService.find(id);
modelMap.addAttribute("pressureLevel",pressureLevel);
return "pressureLevel/edit";
}
@RequestMapping("save")
@ResponseBody
public RespData save(PressureLevel pressureLevel){
if (pressureLevelService.findByAttribute("name",pressureLevel.getName()) != null){
return RespData.error(pressureLevel.getName()+"已存在");
}
pressureLevelService.save(pressureLevel);
return RespData.success();
}
@RequestMapping("update")
@ResponseBody
public RespData update(PressureLevel pressureLevel){
PressureLevel source = pressureLevelService.findByAttribute("name",pressureLevel.getName());
if (source != null && !source.getId().equals(pressureLevel.getId())){
return RespData.error(pressureLevel.getName()+"已存在");
}
pressureLevelService.update(pressureLevel);
return RespData.success();
}
@RequestMapping("delete")
@ResponseBody
public Message delete(Long ids){
pressureLevelService.delete(ids);
return Message.success("删除成功");
}
/**
* 导入模板
*/
@RequestMapping("/exportTemplate")
public void exportTemplate(HttpServletResponse response) {
pressureLevelService.exportTemplate(response);
}
@RequestMapping("import")
@ResponseBody
public RespData importExcel(MultipartFile file) {
try {
pressureLevelService.importExcel(file);
return RespData.success();
} catch (RuntimeException e) {
return RespData.error(e.getMessage());
} catch (Exception e) {
return RespData.error("导入失败");
}
}
}

View File

@@ -0,0 +1,80 @@
package com.vverp.controller.admin;
import com.vverp.annotation.Module;
import com.vverp.entity.*;
import com.vverp.moli.util.RespData;
import com.vverp.service.PrintSettingService;
import com.vverp.service.TableStorageService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author dealsky
* @date 2020/4/24 9:46 上午
*/
@Controller("adminPrintSettingController")
@RequestMapping("/admin/printSetting")
public class PrintSettingController extends BaseController {
private static final Class[] ENABLE_CLASSES = new Class[]{ PurchaseOrder.class, PurchaseStock.class,};
@Resource
private PrintSettingService printSettingService;
@Resource
private TableStorageService tableStorageService;
@RequestMapping("/list")
public String list(ModelMap modelMap) {
List<Map<String, Object>> list = new ArrayList<>();
for (Class cls : ENABLE_CLASSES) {
Map<String, Object> map = new HashMap<>();
Module module = (Module) cls.getAnnotation(Module.class);
map.put("moduleName", module.name());
PrintSetting printSetting = printSettingService.get(cls);
map.put("printSetting", printSetting);
list.add(map);
}
modelMap.addAttribute("list", list);
modelMap.addAttribute("paperTypes", PrintSetting.PaperType.values());
modelMap.addAttribute("printDirections", PrintSetting.PrintDirection.values());
return "/printSetting/list";
}
@RequestMapping(value = "/update", method = RequestMethod.POST)
@ResponseBody
public RespData update(@RequestBody List<PrintSetting> list) {
try {
printSettingService.update(list);
} catch (Exception e) {
e.printStackTrace();
return RespData.error("保存失败");
}
return RespData.success();
}
@RequestMapping("/data")
@ResponseBody
public RespData data(String name) {
String headerName = "inside-" + name + "-header-print";
String bodyName = "inside-" + name + "-print";
Map<String, Object> map = new HashMap<>();
map.put("headerFields", tableStorageService.findByName(headerName+ "_fields"));
map.put("bodyFields", tableStorageService.findByName(bodyName+ "_fields"));
map.put("bodyColumns", tableStorageService.findByName(bodyName+ "_columns"));
map.put("printSetting", printSettingService.get(name));
return RespData.success(map);
}
}

View File

@@ -0,0 +1,313 @@
package com.vverp.controller.admin;
import com.vverp.base.Setting;
import com.vverp.dto.ProductBaseDTO;
import com.vverp.entity.*;
import com.vverp.enums.OrderStatus;
import com.vverp.moli.util.*;
import com.vverp.service.*;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.ui.ModelMap;
import org.springframework.web.multipart.MultipartFile;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
@Controller("adminProductController")
@RequestMapping("/admin/product")
public class ProductController extends BaseController {
@Resource
private ProductService productService;
@Resource
private ProductTypeService productTypeService;
@Resource
private PurchaseOrderItemService purchaseOrderItemService;
@Resource
private ProgressStockService progressStockService;
@Resource
private AdminService adminService;
@RequestMapping("stockList")
public String stockList(Pageable pageable,ModelMap modelMap,String name,String code,Long productTypeId){
Admin admin = adminService.getCurrent();
progressStockService.createStock(admin.getNowProgress());
Page<ProgressStock> page = progressStockService.findPageView(pageable,admin.getNowProgress(),name,code,productTypeId);
for (ProgressStock progressStock : page.getContent()){
Product product = progressStock.getProduct();
if (product.getProductType() != null) {
if (product.getProductType().getParentId() != null){
ProductType parent = productTypeService.find(product.getProductType().getParentId());
progressStock.setProductType(parent.getName()+"/"+product.getProductType().getName());
}else {
progressStock.setProductType(product.getProductType().getName());
}
}
}
modelMap.addAttribute("page",page);
modelMap.addAttribute("name",name);
modelMap.addAttribute("code",code);
modelMap.addAttribute("productTypes",productTypeService.findAll());
modelMap.addAttribute("productTypeId",productTypeId);
// modelMap.addAttribute("productTypeId",productTypeId);
return "product/conduit/stockList";
}
@RequestMapping("editStock")
public String editStock(Long id,ModelMap modelMap){
ProgressStock progressStock = progressStockService.find(id);
modelMap.addAttribute("progressStock",progressStock);
return "product/conduit/editStock";
}
@RequestMapping("updateStock")
@ResponseBody
public RespData updateStock(Long id,BigDecimal stockCount){
ProgressStock progressStock = progressStockService.find(id);
progressStock.setStockCount(stockCount);
progressStockService.update(progressStock);
return RespData.success("保存成功");
}
@RequestMapping("/list")
public String list(Pageable pageable, Date createDateStart, Date createDateEnd, String name, String code,
BigDecimal retailPrice, String format, BigDecimal gWeight, String pattern, String colour,
Long productTypeId, String productTypeChain, String treeId, ModelMap modelMap,Product.Type type) {
Page<Product> page = productService.findPageView(pageable, createDateStart, createDateEnd, name, code, retailPrice, format, gWeight, pattern, colour, productTypeId, productTypeChain,type);
Map<Long,String> typeChan = new HashMap<>();
for (Product product : page.getContent()){
if (product.getProductType() != null) {
if (product.getProductType().getParentId() != null){
ProductType parent = productTypeService.find(product.getProductType().getParentId());
typeChan.put(product.getId(), parent.getName()+"/"+product.getProductType().getName());
}else {
typeChan.put(product.getId(), product.getProductType().getName());
}
}else {
typeChan.put(product.getId(), "");
}
}
modelMap.addAttribute("page", page);
modelMap.addAttribute("typeChan", typeChan);
modelMap.addAttribute("createDateStart", createDateStart);
modelMap.addAttribute("createDateEnd", createDateEnd);
modelMap.addAttribute("name", name);
modelMap.addAttribute("code", code);
modelMap.addAttribute("type", type);
modelMap.addAttribute("retailPrice", retailPrice);
modelMap.addAttribute("format", format);
modelMap.addAttribute("gWeight", gWeight);
modelMap.addAttribute("pattern", pattern);
modelMap.addAttribute("colour", colour);
modelMap.addAttribute("productTypeId", productTypeId);
modelMap.addAttribute("productTypes", productTypeService.findAll());
modelMap.addAttribute("treeId", treeId);
modelMap.addAttribute("productTypeChain", productTypeChain);
return "/product"+"/"+type.name()+"/list";
}
@RequestMapping("/add")
public String add(ModelMap modelMap, Product.Type type) {
// modelMap.addAttribute("productTypes", productTypeService.findAll());
modelMap.addAttribute("type", type);
modelMap.addAttribute("productRate", Setting.getData().getProductRate());
return "/product"+"/"+type.name()+"/add";
}
@RequestMapping("/save")
@ResponseBody
public Message save(Product product) {
// if (!isValid(product, BaseEntity.Save.class)) {
// return ERROR;
// }
try {
productService.saveProduct(product);
return SUCCESS;
} catch (RuntimeException e) {
return Message.error(e.getMessage());
}
}
@RequestMapping(value = "/view")
public String view(Long id, ModelMap modelMap) {
Product product = productService.find(id);
modelMap.addAttribute("product", product);
if (product.getProductType() != null) {
if (product.getProductType().getParentId() != null){
ProductType parent = productTypeService.find(product.getProductType().getParentId());
modelMap.addAttribute("typeName", parent.getName()+"/"+product.getProductType().getName());
}else {
modelMap.addAttribute("typeName", product.getProductType().getName());
}
}else {
modelMap.addAttribute("typeName", "");
}
return "/product"+"/"+product.getType().name()+"/view";
}
@RequestMapping(value = "/edit")
public String edit(Long id, ModelMap modelMap) {
Product product = productService.find(id);
// modelMap.addAttribute("productTypes", productTypeService.findAll());
modelMap.addAttribute("product", product);
modelMap.addAttribute("productRate", Setting.getData().getProductRate());
return "/product"+"/"+product.getType().name()+"/edit";
}
@RequestMapping("/update")
@ResponseBody
public Message update(Product product) {
// if (!isValid(product, BaseEntity.Update.class)) {
// return ERROR;
// }
try {
productService.updateProduct(product);
return SUCCESS;
} catch (RuntimeException e) {
return Message.error(e.getMessage());
}
}
@RequestMapping(value = "/delete", method = RequestMethod.POST)
@ResponseBody
public Message delete(Long ids) {
productService.delete(ids);
return SUCCESS;
}
@RequestMapping("/find")
@ResponseBody
public RespData find(Long id) {
Map<String, Object> map = new HashMap<>();
Product product = productService.find(id);
map.put("product", product);
if (product.getProductType() != null && product.getProductType().getParentId() != null){
ProductType bigType = productTypeService.find(product.getProductType().getParentId());
map.put("bigName", bigType.getName());
map.put("smallName", product.getProductType().getName());
}else if (product.getProductType() != null){
map.put("bigName", product.getProductType().getName());
map.put("smallName", " ");
}else {
map.put("bigName", " ");
map.put("smallName", " ");
}
return RespData.success(map);
}
@RequestMapping("/findByCode")
@ResponseBody
public RespData findByCode(String code) {
Map<String, Object> map = new HashMap<>();
Product product = productService.findByCode(code);
map.put("product", product);
return RespData.success(map);
}
/**
* 导出
*/
@RequestMapping("/export")
public void export(HttpServletResponse response, Date createDateStart, Date createDateEnd, String name, String code, BigDecimal retailPrice, String format, BigDecimal gWeight, String pattern, String colour, Long productTypeId, String productTypeChain, Product.Type type) {
productService.export(response, createDateStart, createDateEnd, name, code, retailPrice, format, gWeight, pattern, colour, productTypeId, productTypeChain,type);
}
/**
* 导出
*/
@RequestMapping("/exportStock")
public void exportStock(HttpServletResponse response,Boolean allStock) {
progressStockService.exportStock(response,allStock);
}
/**
* 导入模板
*/
@RequestMapping("/exportTemplate")
public void exportTemplate(HttpServletResponse response) {
productService.exportTemplate(response);
}
@RequestMapping("/import")
@ResponseBody
public RespData importExcel(MultipartFile file) {
try {
productService.importExcel(file);
return RespData.success();
} catch (RuntimeException e) {
return RespData.error(e.getMessage());
} catch (Exception e) {
return RespData.error("导入失败");
}
}
@RequestMapping("/dialog/select")
public String dialogSelect() {
return "/product/dialog/select";
}
@RequestMapping("/listAll")
@ResponseBody
public RespData listAll(Long productTypeId, String search) {
try {
ProductType productType = productTypeService.find(productTypeId);
List<ProductBaseDTO> list = productService.listAll(productType != null ? productType.getChain() : null, search);
return RespData.success(list);
} catch (Exception e) {
e.printStackTrace();
return RespData.error("获取失败");
}
}
@RequestMapping("/selectPage")
@ResponseBody
public RespData selectPage(Pageable pageable) {
return RespData.success(productService.selectPage(pageable));
}
@RequestMapping("/forecastInventory")
public String forecastInventory(ModelMap modelMap, Pageable pageable, String name) {
if (StringUtils.isNotBlank(name)) {
pageable.setFilters(Collections.singletonList(Filter.like("name", "%" + name + "%")));
}
Page<Product> page = productService.findPage(pageable);
List<Map<String, Object>> list = new ArrayList<>();
for (Product product : page.getContent()) {
Map<String, Object> map = new HashMap<>();
map.put("id", product.getId());
map.put("name", product.getName());
BigDecimal count = BigDecimal.ZERO;
List<PurchaseOrderItem> purchaseOrderItemList = purchaseOrderItemService.findList(null, Arrays.asList(
Filter.eq("productId", product.getId()),
Filter.in("purchaseOrder.status", Arrays.asList(OrderStatus.approved, OrderStatus.completed))
), null);
for (PurchaseOrderItem purchaseOrderItem : purchaseOrderItemList) {
if (purchaseOrderItem.getCount() != null) {
count = count.add(purchaseOrderItem.getCount());
}
}
map.put("count", count.setScale(3, RoundingMode.HALF_UP));
list.add(map);
}
modelMap.addAttribute("name", name);
modelMap.addAttribute("page", new Page<>(list, page.getTotal(), page.getPageable()));
return "/product/forecastInventory";
}
}

View File

@@ -0,0 +1,100 @@
package com.vverp.controller.admin;
import com.vverp.entity.ProductType;
import com.vverp.moli.util.Order;
import com.vverp.moli.util.RespData;
import com.vverp.service.ProductTypeService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* @author dealsky
* @date 2020/3/11 9:34 上午
*/
@Controller("adminProductTypeController")
@RequestMapping("/admin/productType")
public class ProductTypeController extends BaseController {
@Resource
private ProductTypeService productTypeService;
@RequestMapping("/list")
public String list() {
return "/productType/list";
}
@RequestMapping("/listAll")
@ResponseBody
public RespData listAll() {
Map<String, Object> map = new HashMap<>();
map.put("list", productTypeService.findList(null, null, Collections.singletonList(Order.asc("sortFactor"))));
return RespData.success(map);
}
@RequestMapping("/dialog/add")
public String dialogAdd(ModelMap modelMap, String level, String parentId) {
modelMap.addAttribute("level", level);
modelMap.addAttribute("parentId", parentId);
return "/productType/dialog/add";
}
@RequestMapping("/dialog/edit")
public String dialogEdit(ModelMap modelMap, Long id) {
modelMap.addAttribute("productType", productTypeService.find(id));
return "/productType/dialog/edit";
}
@RequestMapping("/save")
@ResponseBody
public RespData save(ProductType productType) {
try {
productTypeService.saveProductType(productType);
}catch (Exception e){
return RespData.error(e.getMessage());
}
return RespData.success();
}
@RequestMapping("/update")
@ResponseBody
public RespData update(ProductType productType) {
try {
productTypeService.updateProductType(productType);
}catch (Exception e){
return RespData.error(e.getMessage());
}
return RespData.success();
}
@RequestMapping("/delete")
@ResponseBody
public RespData delete(Long id) {
ProductType productType = productTypeService.find(id);
try {
productTypeService.deleteProductType(productType);
return RespData.success();
} catch (RuntimeException e) {
return RespData.error(e.getMessage());
}
}
@RequestMapping("/selectTree")
@ResponseBody
public RespData selectTree() {
return RespData.success(productTypeService.productTypeTree());
}
@RequestMapping("getChild")
@ResponseBody
public RespData getChild(Long id){
return RespData.success(productTypeService.findByParent(id));
}
}

View File

@@ -0,0 +1,91 @@
package com.vverp.controller.admin;
import com.vverp.entity.Progress;
import com.vverp.moli.util.Message;
import com.vverp.moli.util.Page;
import com.vverp.moli.util.Pageable;
import com.vverp.moli.util.RespData;
import com.vverp.service.ProgressService;
import com.vverp.service.ProgressUnitService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
@RequestMapping("admin/progress")
@Controller("adminProgress")
public class ProgressController extends BaseController{
@Resource
private ProgressService progressService;
@Resource
private ProgressUnitService progressUnitService;
@RequestMapping("list")
public String list(ModelMap modelMap, Pageable pageable){
Page<Progress> page = progressService.findPage(pageable);
modelMap.addAttribute("page",page);
return "progress/list";
}
@RequestMapping("add")
public String add(ModelMap modelMap){
modelMap.addAttribute("unitList",progressUnitService.findAll());
return "progress/add";
}
@RequestMapping("edit")
public String edit(Long id,ModelMap modelMap){
Progress progress = progressService.find(id);
modelMap.addAttribute("unitList",progressUnitService.findAll());
modelMap.addAttribute("progress",progress);
return "progress/edit";
}
@RequestMapping("save")
@ResponseBody
public RespData save(Progress progress){
if(progress.getCode() == null){
return RespData.error("项目号不能为空");
}
if (progressService.findByCode(progress.getCode(),null,null) != null){
return RespData.error("项目号已存在");
}
if(progress.getName() == null){
return RespData.error("项目名称不能为空");
}
if (progressService.findByCode(null,progress.getName(),null) != null){
return RespData.error("项目名称已存在");
}
progressService.save(progress);
return RespData.success();
}
@RequestMapping("update")
@ResponseBody
public RespData update(Progress progress){
if(progress.getCode() == null){
return RespData.error("项目号不能为空");
}
if (progressService.findByCode(progress.getCode(),null,progress.getId()) != null){
return RespData.error("项目号已存在");
}
if(progress.getName() == null){
return RespData.error("项目名称不能为空");
}
if (progressService.findByCode(null,progress.getName(),progress.getId()) != null){
return RespData.error("项目名称已存在");
}
progressService.update(progress);
return RespData.success();
}
@RequestMapping("delete")
@ResponseBody
public Message delete(Long[] ids){
progressService.delete(ids);
return Message.success("删除成功");
}
}

View File

@@ -0,0 +1,78 @@
package com.vverp.controller.admin;
import com.vverp.entity.ProgressUnit;
import com.vverp.moli.util.Message;
import com.vverp.moli.util.Page;
import com.vverp.moli.util.Pageable;
import com.vverp.moli.util.RespData;
import com.vverp.service.ProgressUnitService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
@RequestMapping("admin/progressUnit")
@Controller("adminProgressUnit")
public class ProgressUnitController extends BaseController{
@Resource
private ProgressUnitService progressUnitService;
@RequestMapping("list")
public String list(ModelMap modelMap, Pageable pageable){
Page<ProgressUnit> page = progressUnitService.findPage(pageable);
modelMap.addAttribute("page",page);
return "progressUnit/list";
}
@RequestMapping("add")
public String add(){
return "progressUnit/add";
}
@RequestMapping("edit")
public String edit(ModelMap modelMap, Long id){
ProgressUnit progressUnit = progressUnitService.find(id);
modelMap.addAttribute("progressUnit",progressUnit);
return "progressUnit/edit";
}
@RequestMapping("save")
@ResponseBody
public RespData save(ProgressUnit progressUnit){
if (progressUnit.getName() == null){
return RespData.error("名称不能为空");
}
if (progressUnitService.findByAttribute("name",progressUnit.getName())!= null){
return RespData.error("单位已存在");
}
progressUnitService.save(progressUnit);
return RespData.success();
}
@RequestMapping("update")
@ResponseBody
public RespData update(ProgressUnit progressUnit){
if (progressUnit.getName() == null){
return RespData.error("名称不能为空");
}
ProgressUnit unit =progressUnitService.findByAttribute("name",progressUnit.getName());
if (unit!= null && !unit.getId().equals(progressUnit.getId())){
return RespData.error("单位已存在");
}
progressUnitService.update(progressUnit);
return RespData.success();
}
@RequestMapping("delete")
@ResponseBody
public Message delete(Long ids){
progressUnitService.delete(ids);
return Message.success("删除成功");
}
}

View File

@@ -0,0 +1,391 @@
package com.vverp.controller.admin;
import com.vverp.config.wx.TemplateMessageContract;
import com.vverp.constant.MainConstant;
import com.vverp.dto.OrderQuery;
import com.vverp.dto.TemplateDTO;
import com.vverp.entity.*;
import com.vverp.enums.ContractType;
import com.vverp.enums.DeliveryType;
import com.vverp.enums.OrderCategory;
import com.vverp.enums.OrderStatus;
import com.vverp.moli.util.*;
import com.vverp.service.*;
import com.vverp.util.Amount2RMB;
import com.vverp.util.CreatePageUtil;
import com.vverp.util.DateUtil;
import org.apache.commons.lang.BooleanUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
/**
* @author dealsky
* @date 2020-03-25 16:50
*/
@Controller
@RequestMapping("/admin/purchaseApplyOrder")
public class PurchaseApplyOrderController extends BaseController {
@Resource
private PurchaseApplyOrderService purchaseApplyOrderService;
@Resource
private PurchaseStockService purchaseStockService;
@Resource
private SupplierService supplierService;
@Resource
private OrderTool orderTool;
@Resource
private PurchaseApplyOrderItemService purchaseApplyOrderItemService;
@Resource
private SystemSettingService systemSettingService;
@Resource
private DepartmentService departmentService;
@Resource
private AdminService adminService;
@Resource
private ProductService productService;
@Resource
private PurchaseApplyOrderItemPriceService purchaseApplyOrderItemPriceService;
@Resource
private ProductTypeService productTypeService;
@Resource
private AdminPurchaseService adminPurchaseService;
@Resource
private ProgressService progressService;
@RequestMapping("/list")
public String list(ModelMap modelMap, Pageable pageable, OrderQuery orderQuery) {
Admin admin = adminService.getCurrent();
modelMap.addAttribute("progressId",orderQuery.getProgressId());
modelMap.addAttribute("progressList",progressService.findAll());
if (orderQuery.getProgressId() == null) {
orderQuery.setProgressId(admin.getNowProgress());
}
if (admin.getNowProgress() == null) {
modelMap.addAttribute("company",true);
}else {
modelMap.addAttribute("company",false);
}
Supplier adminSupplier = null;
if(admin.getSupplierList().size()>0){
for (Supplier findSupplier : admin.getSupplierList()){
if (admin.getNowProgress()==null){
if (findSupplier.getProgressId() == null){
adminSupplier = findSupplier;
}
}else {
if (admin.getNowProgress().equals(findSupplier.getProgressId())){
adminSupplier = findSupplier;
}
}
}
}
modelMap.addAttribute("supplier",false);
if (adminSupplier != null) {
orderQuery.setOwnerId(adminSupplier.getId());
modelMap.addAttribute("supplier",true);
}
orderQuery.setVisibleCompanyIdsStr(adminService.getCurrent().getVisibleCompanyIdsStr());
orderQuery.setVisibleDepartmentIdsStr(adminService.getCurrent().getVisibleDepartmentIdsStr());
orderTool.listCommonAttr(modelMap, pageable, orderQuery, PurchaseApplyOrder.class, purchaseApplyOrderService, purchaseApplyOrderItemService);
modelMap.addAttribute("ownerList", supplierService.findAll());
// modelMap.addAttribute("contractTypes", ContractType.values());
// modelMap.addAttribute("contractType", orderQuery.getContractType());
modelMap.addAttribute("productList", productService.findAll());
modelMap.addAttribute("type", orderQuery.getApplyType());
modelMap.addAttribute("orderQuery", orderQuery);
return "/purchaseApplyOrder/" + orderQuery.getApplyType().name() + "/list";
}
@RequestMapping("/add")
public String add(ModelMap modelMap, PurchaseApplyOrder.Type type) {
Admin admin = adminService.getCurrent();
orderTool.addCommonAttr(modelMap, OrderCategory.purchase);
modelMap.addAttribute("type", type);
modelMap.addAttribute("progressId",admin.getNowProgress());
if (type.equals(PurchaseApplyOrder.Type.device)) {
modelMap.addAttribute("productList", productService.findByType(Product.Type.device));
} else {
modelMap.addAttribute("productList", productService.findByType(Product.Type.conduit));
}
return "/purchaseApplyOrder/" + type.name() + "/add";
}
@RequestMapping("/view")
public String view(ModelMap modelMap, Long id, Integer nowVersion, Integer oldVersion, Boolean showDifferent,String key,String value) {
modelMap.addAttribute("key",key==null?" ":key);
modelMap.addAttribute("value",value);
PurchaseApplyOrder purchaseApplyOrder = purchaseApplyOrderService.find(id);
if (nowVersion == null) {
nowVersion = purchaseApplyOrder.getVersionNum();
}
List<PurchaseApplyOrderItem> itemList = purchaseApplyOrderItemService.findByVersionNum(nowVersion,id);
Map<Integer,Object> map = new HashMap<>();
if (showDifferent != null && showDifferent) {
List<PurchaseApplyOrderItem> oldList = purchaseApplyOrderItemService.findByVersionNum(oldVersion,id);
for (PurchaseApplyOrderItem orderItem : oldList){
map.put(orderItem.getInd(),orderItem);
}
}
modelMap.addAttribute("map",map);
purchaseApplyOrder.setPurchaseApplyOrderItemList(itemList);
List<Integer> versionList = new ArrayList<>();
List<Integer> allVersionList = new ArrayList<>();
for (Integer i = nowVersion; i >= 0; i--) {
versionList.add(i);
}
for (Integer i = purchaseApplyOrder.getVersionNum(); i >= 0; i--) {
allVersionList.add(i);
}
modelMap.addAttribute("allVersionList", allVersionList);
modelMap.addAttribute("versionList", versionList);
modelMap.addAttribute("oldVersion", oldVersion);
modelMap.addAttribute("nowVersion", nowVersion);
modelMap.addAttribute("purchaseApplyOrder", purchaseApplyOrder);
modelMap.addAttribute("type", purchaseApplyOrder.getType());
modelMap.addAttribute("showDifferent",BooleanUtils.isTrue(showDifferent));
return "/purchaseApplyOrder/" + purchaseApplyOrder.getType().name() + "/view";
}
@RequestMapping("/edit")
public String edit(ModelMap modelMap, Long id) {
orderTool.addCommonAttr(modelMap, OrderCategory.purchase);
PurchaseApplyOrder purchaseApplyOrder = purchaseApplyOrderService.find(id);
List<PurchaseApplyOrderItem> itemList = purchaseApplyOrderItemService.findByVersionNum(purchaseApplyOrder.getVersionNum(),id);
Admin admin = adminService.getCurrent();
boolean supplierFlag = false;
for (Role role : admin.getRoles()){
if (role.getChineseName().equals("供应商")){
supplierFlag = true;
}
}
if (!supplierFlag){
for (PurchaseApplyOrderItem item : itemList){
List<AdminPurchase> adminPurchaseList = adminPurchaseService.findByAdmin(admin.getId(),item.getProductTypeId(),admin.getNowProgress());
ProductType productType = productTypeService.find(item.getProductTypeId());
if (productType != null && productType.getParentId() != null) {
List<AdminPurchase> adminPurchaseList2 = adminPurchaseService.findByAdmin(admin.getId(), productType.getParentId(),admin.getNowProgress());
adminPurchaseList.addAll(adminPurchaseList2);
}
if (adminPurchaseList.size()>0){
item.setCanChangePrice(true);
}else {
item.setCanChangePrice(false);
// ProductType productType = productTypeService.find(item.getProductTypeId());
// if (productType.getParentId() != null && admin.getProductTypeIds().contains(productType.getParentId())) {
// item.setCanChangePrice(true);
// }
}
}
}else {
for (PurchaseApplyOrderItem item : itemList){
item.setCanChangePrice(true);
}
}
purchaseApplyOrder.setPurchaseApplyOrderItemList(itemList);
modelMap.addAttribute("purchaseApplyOrder", purchaseApplyOrder);
modelMap.addAttribute("type", purchaseApplyOrder.getType());
if (purchaseApplyOrder.getType().equals(PurchaseApplyOrder.Type.device)) {
modelMap.addAttribute("productList", productService.findByType(Product.Type.device));
} else {
modelMap.addAttribute("productList", productService.findByType(Product.Type.conduit));
}
return "/purchaseApplyOrder/" + purchaseApplyOrder.getType().name() + "/edit";
}
@RequestMapping("/save")
@ResponseBody
public RespData save(PurchaseApplyOrder purchaseApplyOrder) {
try {
purchaseApplyOrder.setVersionNum(0);
purchaseApplyOrderService.savePurchaseApplyOrder(purchaseApplyOrder);
return RespData.success("保存成功");
} catch (Exception e) {
e.printStackTrace();
return RespData.error(e.getMessage());
}
}
@RequestMapping("/update")
@ResponseBody
public RespData update(PurchaseApplyOrder purchaseApplyOrder) {
try {
// purchaseApplyOrderService.updatePurchaseApplyOrder(purchaseApplyOrder);
purchaseApplyOrderService.updatePrice(purchaseApplyOrder);
return RespData.success("保存成功");
} catch (Exception e) {
e.printStackTrace();
return RespData.error(e.getMessage());
}
}
@RequestMapping("/delete")
@ResponseBody
public Message delete(Long[] ids) {
purchaseApplyOrderService.delete(ids);
return SUCCESS;
}
@RequestMapping("/exportSupplier")
public void exportSupplier(HttpServletResponse response, Long id) throws Exception {
// purchaseApplyOrderService.exportSupplier(response, id);
purchaseApplyOrderService.exportSupplierSingle(response, id);
}
//批量导出报价单
@RequestMapping("/exportSupplierSingleAll")
public void exportSupplierSingleAll(HttpServletResponse response, Long[] ids) throws Exception {
// purchaseApplyOrderService.exportSupplier(response, id);
purchaseApplyOrderService.exportSupplierSingleAll(response, ids);
}
//批量发送报价单
@RequestMapping("/sendSupplierAll")
@ResponseBody
public Message sendSupplierAll( Long[] ids) throws Exception {
try {
purchaseApplyOrderService.sendSupplierAll(ids);
return Message.success("发送成功");
}catch (Exception e){
e.printStackTrace();
return Message.error("发送失败");
}
}
@RequestMapping("dialog/addPrice")
public String dialogAddPrice(Long id, ModelMap modelMap) {
modelMap.addAttribute("id", id);
return "purchaseApplyOrder/dialog/addPrice";
}
@RequestMapping("dialog/priceView")
public String dialogPriceView(Long id, ModelMap modelMap) {
PurchaseApplyOrderItem item = purchaseApplyOrderItemService.find(id);
modelMap.addAttribute("list", item.getPurchaseApplyOrderItemPriceList());
return "purchaseApplyOrder/dialog/priceView";
}
/**
* 导入报价单
*/
@RequestMapping(value = "/uploadExcel", method = RequestMethod.POST)
@ResponseBody
public RespData uploadExcel(MultipartFile file) {
if (file == null) {
return RespData.error("文件为空");
}
//获得文件名
String fileName = file.getOriginalFilename();
//判断文件是否是excel文件
if (!fileName.endsWith("xls") && !fileName.endsWith("xlsx")) {
return RespData.error("不是excel文件");
}
try {
purchaseApplyOrderItemPriceService.ExcelSendData(file);
return RespData.success("发货成功");
} catch (Exception e) {
e.printStackTrace();
return RespData.error(e.getMessage());
}
}
@RequestMapping("confirmSupplier")
@ResponseBody
public RespData confirmSupplier(Long id) {
purchaseApplyOrderItemPriceService.confirmSupplier(id);
return RespData.success();
}
@RequestMapping("dialog/addFile")
public String dialogAddFile (ModelMap modelMap){
Admin admin = adminService.getCurrent();
modelMap.addAttribute("adminId",admin.getId());
return "purchaseApplyOrder/dialog/addFile";
}
/**
* 导入请购单
*/
@RequestMapping(value = "/uploadOrderExcel", method = RequestMethod.POST)
@ResponseBody
public RespData uploadOrderExcel(MultipartFile file,Long adminId) {
if (file == null) {
return RespData.error("文件为空");
}
//获得文件名
String fileName = file.getOriginalFilename();
//判断文件是否是excel文件
if (!fileName.endsWith("xls") && !fileName.endsWith("xlsx")) {
return RespData.error("不是excel文件");
}
try {
purchaseApplyOrderService.saveFile(file,adminId);
return RespData.success("发货成功");
}catch (Exception e){
e.printStackTrace();
return RespData.error(e.getMessage());
}
}
@RequestMapping("createByMaterial")
@ResponseBody
public RespData createByMaterial(String ids,String preTitle,Integer flowNum,Long adminId,Long[] bigTypeIds,Long[] smallTypeIds){
try {
purchaseApplyOrderService.createByMaterial(ids,preTitle,flowNum,adminId,bigTypeIds, smallTypeIds);
}catch (Exception e){
e.printStackTrace();
return RespData.error(e.getMessage());
}
return RespData.success("保存成功");
}
@RequestMapping("/export")
public void export(HttpServletResponse response,OrderQuery orderQuery) {
Admin admin = adminService.getCurrent();
Supplier adminSupplier = null;
if(admin.getSupplierList().size()>0){
for (Supplier findSupplier : admin.getSupplierList()){
if (admin.getNowProgress()==null){
if (findSupplier.getProgressId() == null){
adminSupplier = findSupplier;
}
}else {
if (admin.getNowProgress().equals(findSupplier.getProgressId())){
adminSupplier = findSupplier;
}
}
}
}
if (adminSupplier != null){
orderQuery.setOwnerId(adminSupplier.getId());
}
orderQuery.setProgressId(admin.getNowProgress());
orderQuery.setVisibleCompanyIdsStr(adminService.getCurrent().getVisibleCompanyIdsStr());
orderQuery.setVisibleDepartmentIdsStr(adminService.getCurrent().getVisibleDepartmentIdsStr());
purchaseApplyOrderService.export(response,orderQuery);
}
}

View File

@@ -0,0 +1,893 @@
package com.vverp.controller.admin;
import com.vverp.util.DateUtil;
import com.vverp.dto.OrderQuery;
import com.vverp.entity.*;
import com.vverp.enums.*;
import com.vverp.moli.util.*;
import com.vverp.service.*;
import com.vverp.util.Amount2RMB;
import com.vverp.util.CreatePageUtil;
import org.apache.commons.lang.BooleanUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
/**
* @author dealsky
* @date 2020-03-25 16:50
*/
@Controller
@RequestMapping("/admin/purchaseOrder")
public class PurchaseOrderController extends BaseController {
@Resource
private PurchaseOrderService purchaseOrderService;
@Resource
private PurchaseStockService purchaseStockService;
@Resource
private SupplierService supplierService;
@Resource
private OrderTool orderTool;
@Resource
private PurchaseOrderItemService purchaseOrderItemService;
@Resource
private SystemSettingService systemSettingService;
@Resource
private DepartmentService departmentService;
@Resource
private AdminService adminService;
@Resource
private ProductService productService;
@Resource
private MaterialOrderService materialOrderService;
@Resource
private MaterialOrderItemService materialOrderItemService;
@Resource
private ProgressService progressService;
@Resource
private SupplierCspService supplierCspService;
// 采购管理-订货管理-合同签订状态(订货管理)
@RequestMapping("/orderList")
public String orderList(ModelMap modelMap, Pageable pageable, OrderQuery orderQuery) {
pageAddProgressData(modelMap, orderQuery);
orderTool.listCommonAttr(modelMap, pageable, orderQuery, PurchaseOrder.class, purchaseOrderService, purchaseOrderItemService);
Map<Long,String> map = new HashMap<>();
Page<PurchaseOrder> page = (Page<PurchaseOrder>) modelMap.get("page");
for (PurchaseOrder purchaseOrder : page.getContent()) {
map.put(purchaseOrder.getId(), purchaseOrderItemService.purchaseOrderStatus(purchaseOrder.getId(), null));
Map<String, Object> lm = new HashMap<>();
lm.put("finishRate", "0%");
BigDecimal totalCount = purchaseOrder.getTotalCount();
BigDecimal completedCount = purchaseOrderItemService.sumInboundCount(purchaseOrder.getId());
if (totalCount != null && completedCount != null && totalCount.compareTo(BigDecimal.ZERO) != 0) {
lm.put("finishRate", completedCount.multiply(new BigDecimal(100)).divide(totalCount, RoundingMode.HALF_UP) + "%");
}
purchaseOrder.setStatistics(lm);
}
modelMap.addAttribute("map", map);
modelMap.addAttribute("materialOrderSn", orderQuery.getMaterialOrderSn());
modelMap.addAttribute("orderType", orderQuery.getOrderType());
return "/purchaseOrder/newList/orderList";
}
// 采购管理-合同管理-合同创建
@RequestMapping("/createContractList")
public String createContractList(ModelMap modelMap, Pageable pageable, OrderQuery orderQuery) {
pageAddProgressData(modelMap, orderQuery);
orderTool.listCommonAttr(modelMap, pageable, orderQuery, PurchaseOrder.class, purchaseOrderService, purchaseOrderItemService);
Map<Long,String> map = new HashMap<>();
Page<PurchaseOrder> page = (Page<PurchaseOrder>) modelMap.get("page");
for (PurchaseOrder purchaseOrder : page.getContent()) {
map.put(purchaseOrder.getId(), purchaseOrderItemService.purchaseOrderStatus(purchaseOrder.getId(), null));
}
modelMap.addAttribute("map", map);
modelMap.addAttribute("materialOrderSn", orderQuery.getMaterialOrderSn());
modelMap.addAttribute("orderType", orderQuery.getOrderType());
return "/purchaseOrder/newList/createContractList";
}
// 采购管理-合同管理-合同台账
@RequestMapping("/contractList")
public String contractList(ModelMap modelMap, Pageable pageable, OrderQuery orderQuery) {
orderQuery.setOrderType(PurchaseOrder.OrderType.contract);
pageAddProgressData(modelMap, orderQuery);
orderTool.listCommonAttr(modelMap, pageable, orderQuery, PurchaseOrder.class, purchaseOrderService, purchaseOrderItemService);
Page<PurchaseOrder> page = (Page<PurchaseOrder>) modelMap.get("page");
purchaseOrderService.addStatistics(page.getContent());
modelMap.addAttribute("contractSn", orderQuery.getContractSn());
modelMap.addAttribute("materialOrderSn", orderQuery.getMaterialOrderSn());
return "/purchaseOrder/newList/contractList";
}
// 采购管理-发货管理-发货合同
@RequestMapping("/deliverGoodsContractList")
public String deliverGoodsContractList(ModelMap modelMap, Pageable pageable, OrderQuery orderQuery) {
orderQuery.setOrderType(PurchaseOrder.OrderType.contract);
pageAddProgressData(modelMap, orderQuery);
orderTool.listCommonAttr(modelMap, pageable, orderQuery, PurchaseOrder.class, purchaseOrderService, purchaseOrderItemService);
return "purchaseOrder/newList/deliverGoodsContractList";
}
public void pageAddProgressData(ModelMap modelMap, OrderQuery orderQuery) {
Admin admin = adminService.getCurrent();
if (orderQuery.getProgressId() == null) {
orderQuery.setProgressId(admin.getNowProgress());
}
orderQuery.setVisibleCompanyIdsStr(admin.getVisibleCompanyIdsStr());
orderQuery.setVisibleDepartmentIdsStr(admin.getVisibleDepartmentIdsStr());
// 用户是否为供应商
boolean isSupplier = Admin.Type.supplier.equals(admin.getType());
if (isSupplier) {
// 供应商
Supplier adminSupplier = null;
for (Supplier findSupplier : admin.getSupplierList()) {
if (Objects.equals(orderQuery.getProgressId(), findSupplier.getProgressId())) {
adminSupplier = findSupplier;
break;
}
}
orderQuery.setOwnerId(Optional.ofNullable(adminSupplier).map(Supplier::getId).orElse(0L));
orderQuery.setBeginOrder(true);
} else {
modelMap.addAttribute("ownerList", supplierService.findByProgressId(orderQuery.getProgressId(), false));
}
modelMap.addAttribute("supplier", isSupplier);
// 项目是否为公司
boolean isCompany = Admin.Type.admin.equals(admin.getType()) && admin.getNowProgress() == null;
modelMap.addAttribute("company", isCompany);
if (isCompany) {
modelMap.addAttribute("progressId", orderQuery.getProgressId());
modelMap.addAttribute("progressList", progressService.findAll());
}
}
// 链接以及相关页面弃用
@RequestMapping("/list")
public String list(ModelMap modelMap, Pageable pageable, OrderQuery orderQuery,String pageType) {
Admin admin = adminService.getCurrent();
modelMap.addAttribute("progressId",orderQuery.getProgressId());
modelMap.addAttribute("progressList",progressService.findAll());
if (orderQuery.getProgressId() == null) {
orderQuery.setProgressId(admin.getNowProgress());
}
modelMap.addAttribute("supplier",false);
Supplier adminSupplier = null;
if (admin.getNowProgress() ==null) {
modelMap.addAttribute("company", true);
}else {
modelMap.addAttribute("company",false);
}
List<Progress> progressList = new ArrayList<>();
Map<Long,Progress> progressMap = new HashMap<>();
for (Progress progress : progressService.findAll()){
progressMap.put(progress.getId(),progress);
}
modelMap.addAttribute("showCompany",false);
for (Supplier findSupplier : admin.getSupplierList()){
if (findSupplier.getProgressId() == null){
modelMap.addAttribute("showCompany",true);
}else {
progressList.add(progressMap.get(findSupplier.getProgressId()));
}
if (admin.getNowProgress()==null){
if (findSupplier.getProgressId() == null){
adminSupplier = findSupplier;
}
}else {
if (admin.getNowProgress().equals(findSupplier.getProgressId())){
adminSupplier = findSupplier;
}
}
}
if (adminSupplier != null){
orderQuery.setOwnerId(adminSupplier.getId());
modelMap.addAttribute("supplier",true);
orderQuery.setBeginOrder(true);
modelMap.addAttribute("progressList",progressList);
}
orderQuery.setVisibleCompanyIdsStr(adminService.getCurrent().getVisibleCompanyIdsStr());
orderQuery.setVisibleDepartmentIdsStr(adminService.getCurrent().getVisibleDepartmentIdsStr());
PurchaseOrder.OrderType orderType = orderQuery.getOrderType();
if (PurchaseOrder.OrderType.order.equals(orderType)) {
orderQuery.setOrderType(null);
if (BooleanUtils.isTrue(orderQuery.getTurnContract())) {
orderQuery.setOrderType(PurchaseOrder.OrderType.contract);
} else if (BooleanUtils.isFalse(orderQuery.getTurnContract())) {
orderQuery.setOrderType(PurchaseOrder.OrderType.order);
}
}
orderTool.listCommonAttr(modelMap, pageable, orderQuery, PurchaseOrder.class, purchaseOrderService, purchaseOrderItemService);
modelMap.addAttribute("ownerList", supplierService.findAll());
modelMap.addAttribute("contractTypes", ContractType.values());
modelMap.addAttribute("contractType", orderQuery.getContractType());
modelMap.addAttribute("productList", productService.findAll());
modelMap.addAttribute("pageType",pageType);
modelMap.addAttribute("orderQuery", orderQuery);
if (PurchaseOrder.OrderType.order.equals(orderType)) {
orderQuery.setOrderType(PurchaseOrder.OrderType.order);
Page<PurchaseOrder> page = (Page<PurchaseOrder>) modelMap.get("page");
// 订货单的订货状态,如“未完成订货(未给供应商发邮件)”、“已完成部分订货(已给供应商发邮件,但未完全订货完毕)”和“已完成订货”
// 未完成订货未给供应商发邮件item的havePurchaseCount都为0
// 已完成部分订货已给供应商发邮件但未完全订货完毕item的havePurchaseCount小于count
// 已完成订货item的havePurchaseCount都不小于count
// 参考 /admin/materialOrder/list
Map<Long,String> map = new HashMap<>();
boolean notTurnContract = !"turnContract".equals(pageType);
for (PurchaseOrder purchaseOrder : page.getContent()) {
map.put(purchaseOrder.getId(), purchaseOrderItemService.purchaseOrderStatus(purchaseOrder.getId(), null));
if (notTurnContract) {
Map<String, Object> lm = new HashMap<>();
lm.put("finishRate", "0%");
BigDecimal totalCount = purchaseOrder.getTotalCount();
BigDecimal completedCount = purchaseOrderItemService.sumInboundCount(purchaseOrder.getId());
if (totalCount != null && completedCount != null && totalCount.compareTo(BigDecimal.ZERO) != 0) {
lm.put("finishRate", completedCount.multiply(new BigDecimal(100)).divide(totalCount, RoundingMode.HALF_UP) + "%");
}
purchaseOrder.setStatistics(lm);
}
}
modelMap.addAttribute("map", map);
return "/purchaseOrder/orderList";
} else if (PurchaseOrder.OrderType.contract.equals(orderType)) {
Page<PurchaseOrder> page = (Page<PurchaseOrder>) modelMap.get("page");
purchaseOrderService.addStatistics(page.getContent());
return "/purchaseOrder/contractList";
}
return "/purchaseOrder/list";
}
// 采购管理-发货管理-发货台账
@RequestMapping("/tzList")
public String tzList(ModelMap modelMap, Pageable pageable, OrderQuery orderQuery) {
orderQuery.setOrderType(PurchaseOrder.OrderType.contract);
pageAddProgressData(modelMap, orderQuery);
orderTool.listCommonAttr(modelMap, pageable, orderQuery, PurchaseOrder.class, purchaseOrderService, purchaseOrderItemService);
return "/purchaseOrder/newList/tzList";
}
/**
* 采购统计(合同台账)
*/
@RequestMapping("/statistics")
public String statistics(ModelMap modelMap, Pageable pageable, OrderQuery query) {
Admin admin = adminService.getCurrent();
query.setProgressId(admin.getNowProgress());
query.setOnlyShow(true);
query.setOrderType(PurchaseOrder.OrderType.contract);
modelMap.addAttribute("supplier",false);
Supplier adminSupplier = null;
for (Supplier findSupplier : admin.getSupplierList()){
if (admin.getNowProgress()==null){
if (findSupplier.getProgressId() == null){
adminSupplier = findSupplier;
}
}else {
if (admin.getNowProgress().equals(findSupplier.getProgressId())){
adminSupplier = findSupplier;
}
}
}
if (adminSupplier != null){
query.setOwnerId(adminSupplier.getId());
modelMap.addAttribute("supplier",true);
}
Page<PurchaseOrder> page = purchaseOrderService.findPage(pageable, query);
modelMap.addAttribute("ownerList", supplierService.findAll());
modelMap.addAttribute("statusList", OrderStatus.getDefaultList());
modelMap.addAttribute("departmentList", departmentService.findAll());
modelMap.addAttribute("contractTypes", ContractType.values());
modelMap.addAttribute("query", query);
List<Map<String, Object>> list = purchaseOrderService.statistics(page.getContent());
modelMap.addAttribute("page", new Page<>(list, page.getTotal(), page.getPageable()));
return "/purchaseOrder/statistics";
}
/**
* 显示料单的订货单哪些已订货、哪些未订货、哪些部分订货
*/
@RequestMapping("/findByMaterialOrder")
public String findByMaterialOrder(ModelMap modelMap, Pageable pageable, OrderQuery orderQuery, Long materialOrderId) {
MaterialOrder materialOrder = materialOrderService.find(materialOrderId);
Integer versionNum = materialOrder.getVersionNum();
orderQuery.setIdList(materialOrderItemService.findPurchaseOrderIdList(versionNum, materialOrderId));
modelMap.addAttribute("materialOrderSn", materialOrder.getSn());
modelMap.addAttribute("materialOrderId", materialOrderId);
Admin admin = adminService.getCurrent();
modelMap.addAttribute("progressId",orderQuery.getProgressId());
modelMap.addAttribute("progressList",progressService.findAll());
if (orderQuery.getProgressId() == null) {
orderQuery.setProgressId(admin.getNowProgress());
}
modelMap.addAttribute("supplier",false);
Supplier adminSupplier = null;
if (admin.getNowProgress() ==null) {
modelMap.addAttribute("company", true);
}else {
modelMap.addAttribute("company",false);
}
List<Progress> progressList = new ArrayList<>();
Map<Long,Progress> progressMap = new HashMap<>();
for (Progress progress : progressService.findAll()){
progressMap.put(progress.getId(),progress);
}
modelMap.addAttribute("showCompany",false);
for (Supplier findSupplier : admin.getSupplierList()){
if (findSupplier.getProgressId() == null){
modelMap.addAttribute("showCompany",true);
}else {
progressList.add(progressMap.get(findSupplier.getProgressId()));
}
if (admin.getNowProgress()==null){
if (findSupplier.getProgressId() == null){
adminSupplier = findSupplier;
}
}else {
if (admin.getNowProgress().equals(findSupplier.getProgressId())){
adminSupplier = findSupplier;
}
}
}
if (adminSupplier != null){
orderQuery.setOwnerId(adminSupplier.getId());
modelMap.addAttribute("supplier",true);
orderQuery.setBeginOrder(true);
modelMap.addAttribute("progressList",progressList);
}
orderQuery.setVisibleCompanyIdsStr(adminService.getCurrent().getVisibleCompanyIdsStr());
orderQuery.setVisibleDepartmentIdsStr(adminService.getCurrent().getVisibleDepartmentIdsStr());
orderQuery.setOrderType(null);
if (BooleanUtils.isTrue(orderQuery.getTurnContract())) {
orderQuery.setOrderType(PurchaseOrder.OrderType.contract);
} else if (BooleanUtils.isFalse(orderQuery.getTurnContract())) {
orderQuery.setOrderType(PurchaseOrder.OrderType.order);
}
orderTool.listCommonAttr(modelMap, pageable, orderQuery, PurchaseOrder.class, purchaseOrderService, purchaseOrderItemService);
modelMap.addAttribute("ownerList", supplierService.findAll());
modelMap.addAttribute("contractTypes", ContractType.values());
modelMap.addAttribute("contractType", orderQuery.getContractType());
modelMap.addAttribute("productList", productService.findAll());
modelMap.addAttribute("orderQuery", orderQuery);
orderQuery.setOrderType(PurchaseOrder.OrderType.order);
Page<PurchaseOrder> page = (Page<PurchaseOrder>) modelMap.get("page");
// 订货单的订货状态,如“未完成订货(未给供应商发邮件)”、“已完成部分订货(已给供应商发邮件,但未完全订货完毕)”和“已完成订货”
// 未完成订货未给供应商发邮件item的havePurchaseCount都为0
// 已完成部分订货已给供应商发邮件但未完全订货完毕item的havePurchaseCount小于count
// 已完成订货item的havePurchaseCount都不小于count
// 参考 /admin/materialOrder/list
Map<Long,String> map = new HashMap<>();
Map<Long,String> totalCountMap = new HashMap<>();
for (PurchaseOrder purchaseOrder : page.getContent()) {
List<Long> purchaseOrderItemIdList = materialOrderItemService.findPurchaseOrderItemIdList(versionNum, materialOrderId, purchaseOrder.getId());
map.put(purchaseOrder.getId(), purchaseOrderItemService.purchaseOrderStatus(null, purchaseOrderItemIdList));
totalCountMap.put(purchaseOrder.getId(), purchaseOrderItemService.sumCount(null, purchaseOrderItemIdList).setScale(3).toPlainString());
}
modelMap.addAttribute("map", map);
modelMap.addAttribute("totalCountMap", totalCountMap);
return "/materialOrder/conduit/purchaseOrderList";
}
@RequestMapping("/add")
public String add(ModelMap modelMap, @RequestParam(defaultValue = "false") Boolean internationalTradeFlag) {
orderTool.addCommonAttr(modelMap, OrderCategory.purchase);
modelMap.addAttribute("internationalTradeFlag", internationalTradeFlag);
return "/purchaseOrder/add";
}
@RequestMapping("/dialog/add")
public String dialogAdd(ModelMap modelMap, Long salesOrderId) {
orderTool.addCommonAttr(modelMap, OrderCategory.purchase);
return "/purchaseOrder/dialog/add";
}
@RequestMapping("/view")
public String view(ModelMap modelMap, Long id) {
Admin admin = adminService.getCurrent();
PurchaseOrder purchaseOrder = purchaseOrderService.find(id);
if (admin.getSupplierList().size()>0){
modelMap.addAttribute("supplier",true);
}else {
modelMap.addAttribute("supplier",false);
}
modelMap.addAttribute("purchaseOrder", purchaseOrder);
modelMap.addAttribute("poiMoMap", purchaseOrderItemService.findIdMaterialOrderIdMap(id));
if (purchaseOrder.getType() != null && purchaseOrder.getType().equals(PurchaseApplyOrder.Type.conduit)){
modelMap.addAttribute("adminList", adminService.findAll());
return "/purchaseOrder/conduit/view";
}
if (purchaseOrder.getType() != null && purchaseOrder.getType().equals(PurchaseApplyOrder.Type.device)){
return "/purchaseOrder/device/view";
}
return "/purchaseOrder/view";
}
/** 台账查看 */
@RequestMapping("/tzView")
public String tzView(ModelMap modelMap, Long id) {
PurchaseOrder purchaseOrder = purchaseOrderService.find(id);
modelMap.addAttribute("purchaseOrder", purchaseOrder);
return "/purchaseOrder/tzView";
}
@RequestMapping("/save")
@ResponseBody
public RespData save(PurchaseOrder purchaseOrder, Boolean approveApplyFlag) {
return respDataWithHandle(() -> {
purchaseOrderService.savePurchaseOrder(purchaseOrder);
if (BooleanUtils.isTrue(approveApplyFlag)) {
purchaseOrderService.approveApply(purchaseOrder);
}
});
}
@RequestMapping("/update")
@ResponseBody
public RespData update(PurchaseOrder purchaseOrder, Boolean approveApplyFlag) {
return respDataWithHandle(() -> {
PurchaseOrder source = purchaseOrderService.updatePurchaseOrder(purchaseOrder);
if (BooleanUtils.isTrue(approveApplyFlag)) {
purchaseOrderService.approveApplyForEdit(source);
}
});
}
/**
* 审批
*
* @return
*/
@RequestMapping("/approve")
@ResponseBody
public RespData approve(Long id) {
PurchaseOrder purchaseOrder = purchaseOrderService.find(id);
try {
purchaseOrderService.approve(purchaseOrder);
return RespData.success();
} catch (RuntimeException e) {
return RespData.error(e.getMessage());
}
}
/**
* 审批申请
*
* @return
*/
@RequestMapping("/approveApply")
@ResponseBody
public RespData approveApply(Long id) {
PurchaseOrder purchaseOrder = purchaseOrderService.find(id);
try {
purchaseOrderService.approveApply(purchaseOrder);
return RespData.success();
} catch (RuntimeException e) {
return RespData.error(e.getMessage());
}
}
/**
* 作废
*
* @return
*/
@RequestMapping("/invalid")
@ResponseBody
public RespData invalid(Long id) {
PurchaseOrder purchaseOrder = purchaseOrderService.find(id);
try {
purchaseOrderService.invalid(purchaseOrder);
return RespData.success();
} catch (RuntimeException e) {
return RespData.error(e.getMessage());
}
}
@RequestMapping("/delete")
@ResponseBody
public Message delete(Long[] ids) {
try {
purchaseOrderService.deleteEntity(ids);
}catch (Exception e){
e.printStackTrace();
return Message.error(e.getMessage());
}
return SUCCESS;
}
@RequestMapping("/dialog/stocks")
public String dialogStocks(ModelMap modelMap, Long id) {
PurchaseOrder purchaseOrder = purchaseOrderService.find(id);
modelMap.addAttribute("list", purchaseStockService.findList(purchaseOrder));
return "/purchaseOrder/dialog/stocks";
}
@RequestMapping("/dialog/invoices")
public String dialogInvoices(ModelMap modelMap, Long id) {
modelMap.addAttribute("id", id);
return "/purchaseOrder/dialog/invoices";
}
/**
* 导入模板
*/
@RequestMapping("/exportTemplate")
public void exportTemplate(HttpServletResponse response) {
purchaseOrderService.exportTemplate(response);
}
@RequestMapping("/import")
@ResponseBody
public RespData importExcel(MultipartFile file) {
try {
purchaseOrderService.importExcel(file);
return RespData.success();
} catch (Exception e) {
return RespData.error("导入失败");
}
}
@RequestMapping("/exportContent")
public void exportContent(HttpServletResponse response, Long id) throws Exception {
purchaseOrderService.exportContent(response, id, false);
}
@RequestMapping("/exportContractAttachment")
public void exportContractAttachment(HttpServletResponse response, Long id) throws Exception {
purchaseOrderService.exportContent(response, id, true);
}
@RequestMapping("/exportContentList")
public void exportContentList(HttpServletResponse response, Long[] ids) throws Exception {
purchaseOrderService.exportContentList(response, ids);
}
/**
* 入库页面
*/
@RequestMapping("/storage")
public String storage(ModelMap modelMap, Long id, Long transportContractId) {
PurchaseOrder purchaseOrder = purchaseOrderService.find(id);
modelMap.addAttribute("purchaseOrder", purchaseOrder);
modelMap.addAttribute("transportContractId", transportContractId);
return "/purchaseOrder/storage";
}
@RequestMapping("print")
public String print(Long id, ModelMap modelMap) {
PurchaseOrder purchaseOrder = purchaseOrderService.find(id);
modelMap.addAttribute("purchaseOrder", purchaseOrder);
modelMap.addAttribute("systemSetting", systemSettingService.findSingle());
modelMap.addAttribute("totalAmount", purchaseOrder.getTotalAmount());
modelMap.addAttribute("totalAmountRMB", Amount2RMB.convert(purchaseOrder.getTotalAmount().setScale(2, RoundingMode.HALF_UP).toString()));
modelMap.addAttribute("method", "");
if (purchaseOrder.getDeliveryType() != null) {
if (purchaseOrder.getDeliveryType().equals(DeliveryType.sendTo)) {
modelMap.addAttribute("method", "(1)");
} else if (purchaseOrder.getDeliveryType().equals(DeliveryType.pickup)) {
modelMap.addAttribute("method", "(2)");
} else {
modelMap.addAttribute("method", "(3)");
}
}
return "purchaseOrder/print";
}
/**
* 待进项发票
*/
@RequestMapping("/beInputInvoice")
@ResponseBody
public RespData beInputInvoice(OrderQuery orderQuery, Pageable pageable) {
List<Map<String, Object>> list = new ArrayList<>();
orderQuery.setStatusList(Arrays.asList(OrderStatus.approved, OrderStatus.completed));
List<PurchaseOrderItem> purchaseOrderItemList = purchaseOrderItemService.findList(orderQuery);
BigDecimal beInputCountSum = BigDecimal.ZERO;
for (PurchaseOrderItem item : purchaseOrderItemList) {
Map<String, Object> map = new HashMap<>();
PurchaseOrder purchaseOrder = item.getPurchaseOrder();
map.put("companyName", purchaseOrder.getCompanyName());
map.put("ownerName", purchaseOrder.getOwnerName());
map.put("productName", item.getName());
map.put("taxPrice", item.getTaxPrice());
map.put("subtotal", item.getSubtotal());
map.put("remark", purchaseOrder.getRemark());
BigDecimal count = (item.getSettlement() != null && item.getSettlement().compareTo(BigDecimal.ZERO) > 0) ? item.getSettlement() : item.getCount();
BigDecimal beInputCount = count.subtract(item.getInvoiceCount());
map.put("beInputCount", beInputCount);
beInputCountSum = beInputCountSum.add(beInputCount);
list.add(map);
}
Page<Map<String, Object>> page = CreatePageUtil.page(list, pageable);
Map<String, Object> map = new HashMap<>();
map.put("page", page);
map.put("beInputCountSum", beInputCountSum);
return RespData.success(map);
}
@RequestMapping("/finishWarehouseStateForItem")
@ResponseBody
public RespData finishWarehouseStateForItem(Long id) {
return respDataWithHandle(() -> {
PurchaseOrderItem purchaseOrderItem = purchaseOrderItemService.find(id);
purchaseOrderItem.setWarehouseState(true);
purchaseOrderItemService.update(purchaseOrderItem);
});
}
@RequestMapping("/updateDynamicInfo")
@ResponseBody
public RespData updateDynamicInfo(Long id, String text) {
return respDataWithHandle(() -> {
PurchaseOrderItem purchaseOrderItem = purchaseOrderItemService.find(id);
purchaseOrderItem.setDynamicInfo(text);
purchaseOrderItemService.update(purchaseOrderItem);
});
}
@RequestMapping("createByApply")
@ResponseBody
public RespData createByApply(String ids, String preTitle, Integer flowNum, Long adminId, String purchaseType, PurchaseOrder.OrderType orderType){
try {
purchaseOrderService.createByApply2(ids,preTitle,flowNum,adminId,purchaseType,orderType);
}catch (Exception e){
e.printStackTrace();
return RespData.error(e.getMessage());
}
return RespData.success("保存成功");
}
@RequestMapping("dialog/createDevice")
public String dialogCreateDevice(ModelMap modelMap,String ids){
modelMap.addAttribute("ids",ids);
modelMap.addAttribute("adminId",adminService.getCurrent().getId());
return "materialOrder/dialog/createDevice";
}
@RequestMapping("createDeviceByApply")
@ResponseBody
public Message createDeviceByApply(String ids,String preTitle,Integer flowNum,Long adminId){
try {
purchaseOrderService.createByDeviceApply(ids,preTitle,flowNum,adminId);
}catch (Exception e){
e.printStackTrace();
return Message.error(e.getMessage());
}
return Message.success("保存成功");
}
@RequestMapping("updateFile")
@ResponseBody
public RespData updateFile(PurchaseOrder purchaseOrder){
purchaseOrderService.updateFile(purchaseOrder);
return RespData.success();
}
@RequestMapping("/exportList")
public void exportList(HttpServletResponse response,OrderQuery orderQuery) {
Admin admin = adminService.getCurrent();
Supplier adminSupplier = null;
for (Supplier findSupplier : admin.getSupplierList()){
if (admin.getNowProgress()==null){
if (findSupplier.getProgressId() == null){
adminSupplier = findSupplier;
}
}else {
if (admin.getNowProgress().equals(findSupplier.getProgressId())){
adminSupplier = findSupplier;
}
}
}
if (adminSupplier != null){
orderQuery.setOwnerId(adminSupplier.getId());
}
orderQuery.setVisibleCompanyIdsStr(adminService.getCurrent().getVisibleCompanyIdsStr());
orderQuery.setVisibleDepartmentIdsStr(adminService.getCurrent().getVisibleDepartmentIdsStr());
purchaseOrderService.exportList(response,orderQuery);
}
/** 导出单个采购单 */
@RequestMapping("/exportSingleData")
public void exportSingleData(HttpServletResponse response, Long id)throws Exception {
purchaseOrderService.exportSingleData(response, id);
}
/** 合同明细导出 */
@RequestMapping("/exportDetailList")
public void exportDetailList(HttpServletResponse response, Long... ids) {
purchaseOrderService.exportDetailList(response, ids);
}
/** 订货明细导出 */
@RequestMapping("/exportDetailList2")
public void exportDetailList2(HttpServletResponse response, Long... ids) {
purchaseOrderService.exportDetailList2(response, ids);
}
/** 台账列表导出 */
@RequestMapping("/exportTzList")
public void exportTzList(HttpServletResponse response,OrderQuery orderQuery) {
Admin admin = adminService.getCurrent();
Supplier adminSupplier = null;
for (Supplier findSupplier : admin.getSupplierList()){
if (admin.getNowProgress()==null){
if (findSupplier.getProgressId() == null){
adminSupplier = findSupplier;
}
}else {
if (admin.getNowProgress().equals(findSupplier.getProgressId())){
adminSupplier = findSupplier;
}
}
}
if (adminSupplier != null){
orderQuery.setOwnerId(adminSupplier.getId());
}
orderQuery.setVisibleCompanyIdsStr(adminService.getCurrent().getVisibleCompanyIdsStr());
orderQuery.setVisibleDepartmentIdsStr(adminService.getCurrent().getVisibleDepartmentIdsStr());
purchaseOrderService.exportTzList(response,orderQuery);
}
/** 合同台账列表导出 */
@RequestMapping("/exportContractTzList")
public void exportContractTzList(HttpServletResponse response, Long... ids) {
purchaseOrderService.exportContractTzList(response, ids);
}
@RequestMapping("getAmount")
@ResponseBody
public RespData getAmount(Long id){
PurchaseOrder purchaseOrder = purchaseOrderService.find(id);
Map<String,Object> map = new HashMap<>();
map.put("totalAmount",purchaseOrder.getTotalAmount());
map.put("totalPay",purchaseOrder.getPaymentAmount());
map.put("ownerId",purchaseOrder.getOwnerId());
map.put("ownerName",purchaseOrder.getOwnerName());
return RespData.success(map);
}
@RequestMapping("dialog/addFile")
public String dialogAddFile(ModelMap modelMap) {
Admin admin = adminService.getCurrent();
modelMap.addAttribute("adminId", admin.getId());
return "purchaseOrder/dialog/addFile";
}
/**
* 导入台账信息
*/
@RequestMapping(value = "/uploadOrderExcel")
@ResponseBody
public RespData uploadOrderExcel(MultipartFile file, Long adminId) {
if (file == null) {
return RespData.error("文件为空");
}
//获得文件名
String fileName = file.getOriginalFilename();
//判断文件是否是excel文件
if (!fileName.endsWith("xls") && !fileName.endsWith("xlsx")) {
return RespData.error("不是excel文件");
}
try {
System.out.println("开始导入文件");
purchaseOrderService.updateFile(file, adminId);
return RespData.success("导入成功");
} catch (Exception e) {
e.printStackTrace();
return RespData.error(e.getMessage());
}
}
@RequestMapping("/conduit/edit")
public String conduitEdit(ModelMap modelMap, Long id) {
PurchaseOrder purchaseOrder = purchaseOrderService.find(id);
modelMap.addAttribute("purchaseOrder", purchaseOrder);
modelMap.addAttribute("poiMoMap", purchaseOrderItemService.findIdMaterialOrderIdMap(id));
modelMap.addAttribute("productList",productService.findAll());
modelMap.addAttribute("adminList", adminService.findAll());
return "/purchaseOrder/conduit/edit";
}
@RequestMapping("/updateCount")
@ResponseBody
public RespData updateCount(PurchaseOrder purchaseOrder) {
purchaseOrderService.updateCount(purchaseOrder);
return RespData.success();
}
@RequestMapping("sendMessage")
@ResponseBody
public RespData sendMessage(Long id) {
PurchaseOrder purchaseOrder = purchaseOrderService.find(id);
Supplier supplier = supplierService.find(purchaseOrder.getOwnerId());
if(supplier.getEmail() == null){
return RespData.error("供应商邮箱不能为空");
}
boolean needPurchase = true;
for (PurchaseOrderItem purchaseOrderItem : purchaseOrder.getPurchaseOrderItemList()){
if (purchaseOrderItem.getPurchaseCount() != null){
needPurchase = false;
break;
}
}
if (needPurchase){
return RespData.error("请先保存订货数量");
}
purchaseOrderService.sendMessage(id);
return RespData.success("发送成功");
}
@RequestMapping("dialog/turnPurchaseOrder")
public String dialogTurnPurchaseOrder(Long id,ModelMap modelMap){
modelMap.addAttribute("id",id);
modelMap.addAttribute("today", DateUtil.formatDate(new Date()));
modelMap.addAttribute("companyAddress", systemSettingService.findSingle().getCompanyAddress());
modelMap.addAttribute("purchaseType", Optional.ofNullable(purchaseOrderService.find(id)).map(PurchaseOrder::getPurchaseType).orElse(null));
return "purchaseOrder/dialog/turnPurchaseOrder";
}
/**转变合同*/
@RequestMapping("turnToContract")
@ResponseBody
public RespData turnToContract(Long id,Integer flowNum,String preTitle, Date signTime, String signPlace, String name, String purchaseType, BigDecimal estimatedAmount){
purchaseOrderService.turnToContract(id,flowNum,preTitle, signTime, signPlace, name, purchaseType, estimatedAmount);
return RespData.success("转变成功");
}
@RequestMapping("dialog/mergePurchaseOrder")
public String dialogMergePurchaseOrder(String ids,ModelMap modelMap){
modelMap.addAttribute("ids",ids);
modelMap.addAttribute("today", DateUtil.formatDate(new Date()));
modelMap.addAttribute("companyAddress", systemSettingService.findSingle().getCompanyAddress());
PurchaseOrder purchaseOrder = null;
Long ownerId = null;
for (String s : ids.split(",")) {
if (purchaseOrder == null) {
purchaseOrder = purchaseOrderService.find(Long.valueOf(s));
ownerId = purchaseOrder.getOwnerId();
} else {
purchaseOrder = purchaseOrderService.find(Long.valueOf(s));
if (!ownerId.equals(purchaseOrder.getOwnerId())) {
throw new RuntimeException("非同一个供应商");
}
}
}
modelMap.addAttribute("purchaseType", purchaseOrder.getPurchaseType());
modelMap.addAttribute("supplierCsp", supplierCspService.findBySupplierId(purchaseOrder.getOwnerId()));
return "purchaseOrder/dialog/mergePurchaseOrder";
}
/**合并成合同*/
@RequestMapping("mergeContract")
@ResponseBody
public RespData mergeContract(String ids,Integer flowNum,String preTitle, String subTitle, String sn, Date signTime, String signPlace, String name, String purchaseType, BigDecimal estimatedAmount){
purchaseOrderService.mergeContract(ids,flowNum,preTitle, subTitle, sn, signTime, signPlace, name, purchaseType, estimatedAmount);
return RespData.success("转变成功");
}
}

View File

@@ -0,0 +1,448 @@
package com.vverp.controller.admin;
import com.vverp.dto.OrderQuery;
import com.vverp.entity.*;
import com.vverp.enums.OrderCategory;
import com.vverp.moli.util.Message;
import com.vverp.moli.util.Page;
import com.vverp.moli.util.Pageable;
import com.vverp.moli.util.RespData;
import com.vverp.service.*;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.*;
/**
* @author dealsky
* @date 2020/2/24 2:37 下午
*/
@Controller("adminPurchaseStockController")
@RequestMapping("/admin/purchaseStock")
public class PurchaseStockController extends BaseController {
@Resource
private PurchaseStockService purchaseStockService;
@Resource
private PurchaseOrderService purchaseOrderService;
@Resource
private SupplierService supplierService;
@Resource
private OrderTool orderTool;
@Resource
private PurchaseStockItemService purchaseStockItemService;
@Resource
private AdminService adminService;
@Resource
private ProductService productService;
@Resource
private ProgressService progressService;
@RequestMapping("/list")
public String list(ModelMap modelMap, Pageable pageable, OrderQuery orderQuery,String pageType) {
/*Admin admin = adminService.getCurrent();
orderQuery.setProgressId(admin.getNowProgress());
modelMap.addAttribute("supplier","false");
Supplier adminSupplier = null;
for (Supplier findSupplier : admin.getSupplierList()){
if (admin.getNowProgress()==null){
if (findSupplier.getProgressId() == null){
adminSupplier = findSupplier;
}
}else {
if (admin.getNowProgress().equals(findSupplier.getProgressId())){
adminSupplier = findSupplier;
}
}
}
if (adminSupplier != null){
orderQuery.setOwnerId(adminSupplier.getId());
modelMap.addAttribute("supplier","true");
}*/
OrderQuery tmp = pageAddProgressData(modelMap, orderQuery);
orderTool.listCommonAttr(modelMap, pageable, orderQuery, PurchaseStock.class, purchaseStockService, purchaseStockItemService);
// modelMap.addAttribute("ownerList", supplierService.findAll());
modelMap.addAttribute("pageType",pageType);
Page<PurchaseStock> page = (Page<PurchaseStock>) modelMap.get("page");
Map<Long, PurchaseOrder> poIdEntityMap = new HashMap<>();
Map<Long, BigDecimal> psIdStockMap = new HashMap<>();
for (PurchaseStock purchaseStock : page.getContent()) {
Long purchaseStockId = purchaseStock.getId();
Long purchaseOrderId = purchaseStock.getPurchaseOrderId();
if (!poIdEntityMap.containsKey(purchaseStockId)) {
poIdEntityMap.put(purchaseStockId, purchaseOrderService.find(purchaseOrderId));
psIdStockMap.put(purchaseStockId, purchaseStockItemService.findSumInStockNumByPurchaseStockId(purchaseStockId));
}
}
modelMap.addAttribute("poIdEntityMap", poIdEntityMap);
modelMap.addAttribute("psIdStockMap", psIdStockMap);
// 合同作为筛选条件,根据公司和供应商筛选
modelMap.addAttribute("purchaseOrderId", orderQuery.getPurchaseOrderId());
modelMap.addAttribute("purchaseOrderList", purchaseOrderService.findList(tmp));
return "/purchaseStock/list";
}
public OrderQuery pageAddProgressData(ModelMap modelMap, OrderQuery orderQuery) {
OrderQuery tmp = new OrderQuery();
Admin admin = adminService.getCurrent();
if (orderQuery.getProgressId() == null) {
orderQuery.setProgressId(admin.getNowProgress());
}
tmp.setProgressId(orderQuery.getProgressId());
orderQuery.setVisibleCompanyIdsStr(admin.getVisibleCompanyIdsStr());
orderQuery.setVisibleDepartmentIdsStr(admin.getVisibleDepartmentIdsStr());
tmp.setVisibleCompanyIdsStr(admin.getVisibleCompanyIdsStr());
tmp.setVisibleDepartmentIdsStr(admin.getVisibleDepartmentIdsStr());
// 用户是否为供应商
boolean isSupplier = Admin.Type.supplier.equals(admin.getType());
if (isSupplier) {
// 供应商
Supplier adminSupplier = null;
for (Supplier findSupplier : admin.getSupplierList()) {
if (Objects.equals(orderQuery.getProgressId(), findSupplier.getProgressId())) {
adminSupplier = findSupplier;
break;
}
}
orderQuery.setOwnerId(Optional.ofNullable(adminSupplier).map(Supplier::getId).orElse(0L));
tmp.setOwnerId(Optional.ofNullable(adminSupplier).map(Supplier::getId).orElse(0L));
// orderQuery.setBeginOrder(true);
} else {
modelMap.addAttribute("ownerList", supplierService.findByProgressId(orderQuery.getProgressId(), false));
}
modelMap.addAttribute("supplier", isSupplier);
// 项目是否为公司
boolean isCompany = Admin.Type.admin.equals(admin.getType()) && admin.getNowProgress() == null;
modelMap.addAttribute("company", isCompany);
if (isCompany) {
modelMap.addAttribute("progressId", orderQuery.getProgressId());
modelMap.addAttribute("progressList", progressService.findAll());
}
return tmp;
}
@RequestMapping("/add")
public String add(ModelMap modelMap, Long purchaseOrderId) {
orderTool.addCommonAttr(modelMap, OrderCategory.purchase);
PurchaseOrder purchaseOrder = purchaseOrderService.find(purchaseOrderId);
if (purchaseOrder != null) {
modelMap.addAttribute("purchaseOrder", purchaseOrder);
}
modelMap.addAttribute("purchaseOrderId", purchaseOrderId);
modelMap.addAttribute("purchaseOrderList", purchaseOrderService.findAvailableList());
return "/purchaseStock/add";
}
@RequestMapping("/dialog/add")
public String dialogAdd(ModelMap modelMap, Long purchaseOrderId) {
orderTool.addCommonAttr(modelMap, OrderCategory.purchase);
PurchaseOrder purchaseOrder = purchaseOrderService.find(purchaseOrderId);
if (purchaseOrder != null) {
modelMap.addAttribute("purchaseOrder", purchaseOrder);
}
modelMap.addAttribute("date", new Date());
return "/purchaseStock/dialog/add";
}
@RequestMapping("/view")
public String view(ModelMap modelMap, Long id) {
PurchaseStock purchaseStock = purchaseStockService.find(id);
modelMap.addAttribute("purchaseStock", purchaseStock);
return "/purchaseStock/view";
}
@RequestMapping("/edit")
public String edit(ModelMap modelMap, Long id) {
orderTool.addCommonAttr(modelMap, OrderCategory.purchase);
PurchaseStock purchaseStock = purchaseStockService.find(id);
modelMap.addAttribute("purchaseStock", purchaseStock);
return "/purchaseStock/edit";
}
@RequestMapping("/inStock")
public String inStock(ModelMap modelMap, Long id) {
orderTool.addCommonAttr(modelMap, OrderCategory.purchase);
PurchaseStock purchaseStock = purchaseStockService.find(id);
modelMap.addAttribute("purchaseStock", purchaseStock);
return "/purchaseStock/inStock";
}
@RequestMapping("/save")
@ResponseBody
public RespData save(PurchaseStock purchaseStock) {
try {
purchaseStockService.saveSalesStock(purchaseStock);
} catch (RuntimeException e) {
e.printStackTrace();
return RespData.error(e.getMessage());
}
return RespData.success();
}
@RequestMapping("/update")
@ResponseBody
public RespData update(PurchaseStock purchaseStock) {
try {
purchaseStockService.updateSalesStock(purchaseStock);
} catch (RuntimeException e) {
e.printStackTrace();
return RespData.error(e.getMessage());
}
return RespData.success();
}
@RequestMapping("/updateTitle")
@ResponseBody
public RespData updateTitle(PurchaseStock purchaseStock) {
try {
purchaseStockService.updateTitle(purchaseStock);
} catch (RuntimeException e) {
e.printStackTrace();
return RespData.error(e.getMessage());
}
return RespData.success();
}
@RequestMapping("/updateStock")
@ResponseBody
public RespData updateStock(PurchaseStock purchaseStock) {
try {
purchaseStockService.updateStock(purchaseStock);
} catch (RuntimeException e) {
e.printStackTrace();
return RespData.error(e.getMessage());
}
return RespData.success();
}
/**
* 审批
*
* @return
*/
@RequestMapping("/approve")
@ResponseBody
public RespData approve(Long id) {
PurchaseStock purchaseStock = purchaseStockService.find(id);
try {
purchaseStockService.approve(purchaseStock);
return RespData.success();
} catch (RuntimeException e) {
return RespData.error(e.getMessage());
}
}
/**
* 审批申请
*
* @return
*/
@RequestMapping("/approveApply")
@ResponseBody
public RespData approveApply(Long id) {
PurchaseStock purchaseStock = purchaseStockService.find(id);
try {
purchaseStockService.approveApply(purchaseStock);
return RespData.success();
} catch (RuntimeException e) {
return RespData.error(e.getMessage());
}
}
/**
* 作废
*
* @return
*/
@RequestMapping("/invalid")
@ResponseBody
public RespData invalid(Long id) {
PurchaseStock purchaseStock = purchaseStockService.find(id);
try {
purchaseStockService.invalid(purchaseStock);
return RespData.success();
} catch (RuntimeException e) {
return RespData.error(e.getMessage());
}
}
/**
* 品质检测页面
*/
@RequestMapping("/detection")
public String detection(ModelMap modelMap, Long id) {
PurchaseStock purchaseStock = purchaseStockService.find(id);
modelMap.addAttribute("purchaseStock", purchaseStock);
return "/purchaseStock/detection";
}
/**
* 检测更新
*/
@RequestMapping("/detectionUpdate")
@ResponseBody
public RespData detectionUpdate(PurchaseStock purchaseStock) {
return respDataWithHandle(() -> purchaseStockService.detectionUpdate(purchaseStock));
}
/**
* 入库页面
*/
@RequestMapping("/storage")
public String storage(ModelMap modelMap, Long id, Long transportContractId) {
PurchaseStock purchaseStock = purchaseStockService.find(id);
modelMap.addAttribute("purchaseStock", purchaseStock);
modelMap.addAttribute("transportContractId", transportContractId);
return "/purchaseStock/storage";
}
@RequestMapping("/delete")
@ResponseBody
public Message delete(Long[] ids) {
purchaseStockService.deleteEntity(ids);
return SUCCESS;
}
@RequestMapping("dialog/addLog")
public String dialogAddLog (ModelMap modelMap){
Admin admin = adminService.getCurrent();
modelMap.addAttribute("adminId",admin.getId());
return "purchaseStock/dialog/addLog";
}
/**
* 导入发货清单
*/
@RequestMapping(value = "/uploadExcel", method = RequestMethod.POST)
@ResponseBody
public RespData uploadExcel(MultipartFile file,Long adminId) {
if (file == null) {
return RespData.error("文件为空");
}
//获得文件名
String fileName = file.getOriginalFilename();
//判断文件是否是excel文件
if (!fileName.endsWith("xls") && !fileName.endsWith("xlsx")) {
return RespData.error("不是excel文件");
}
try {
purchaseStockService.ExcelSendData(file,adminId);
return RespData.success("发货成功");
}catch (Exception e){
e.printStackTrace();
return RespData.error(e.getMessage());
}
}
/**上传导出模板*/
@RequestMapping("dialog/importTemplate")
public String dialogImportTemplate (ModelMap modelMap){
Admin admin = adminService.getCurrent();
modelMap.addAttribute("adminId",admin.getId());
return "purchaseStock/dialog/importTemplate";
}
@RequestMapping(value = "/uploadTemplate", method = RequestMethod.POST)
@ResponseBody
public RespData uploadTemplate(MultipartFile file,Long adminId) {
if (file == null) {
return RespData.error("文件为空");
}
//获得文件名
String fileName = file.getOriginalFilename();
//判断文件是否是excel文件
if (!fileName.endsWith("xlsx")) {
return RespData.error("不是.xlsx文件");
}
try {
purchaseStockService.uploadTemplate(file,adminId);
return RespData.success("发货成功");
}catch (Exception e){
e.printStackTrace();
return RespData.error(e.getMessage());
}
}
/**导出发货单*/
@RequestMapping("/export")
public void export(HttpServletResponse response, Long id) {
purchaseStockService.export3(response, id, true);
}
/**导出入库单*/
@RequestMapping("/exportInStock")
public void exportInStock(HttpServletResponse response, Long id) {
purchaseStockService.export3(response, id, false);
}
/**入库管理-导出*/
@RequestMapping("/exportList")
public void exportList(HttpServletResponse response,OrderQuery orderQuery) {
Admin admin = adminService.getCurrent();
Supplier adminSupplier = null;
for (Supplier findSupplier : admin.getSupplierList()){
if (admin.getNowProgress()==null){
if (findSupplier.getProgressId() == null){
adminSupplier = findSupplier;
}
}else {
if (admin.getNowProgress().equals(findSupplier.getProgressId())){
adminSupplier = findSupplier;
}
}
}
if (adminSupplier != null){
orderQuery.setOwnerId(adminSupplier.getId());
}
purchaseStockService.exportList(response,orderQuery);
}
/**入库管理-批量导出*/
@RequestMapping("/exportAll")
public void exportAll(HttpServletResponse response, Long[] ids) {
purchaseStockService.exportAll(response, ids);
}
/**导入入库单*/
@RequestMapping("dialog/addFile")
public String addFile(ModelMap modelMap){
modelMap.addAttribute("progressId",adminService.getCurrent().getNowProgress());
return "purchaseStock/dialog/addFile";
}
@RequestMapping("/importExcel")
@ResponseBody
public Map<String, Object> importExcel(MultipartFile file,Long progressId,Long purchaseStockId) {
try {
return purchaseStockItemService.importExcel(file,progressId,purchaseStockId);
} catch (Exception e) {
e.printStackTrace();
return new HashMap<>();
}
}
}

View File

@@ -0,0 +1,13 @@
package com.vverp.controller.admin;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* @author dealsky
* @date 2021-06-30 10:47
*/
@Controller
@RequestMapping("/admin/resendMessage")
public class ResendMessageController extends BaseController {
}

View File

@@ -0,0 +1,121 @@
package com.vverp.controller.admin;
import com.vverp.entity.Role;
import com.vverp.enums.DataRange;
import com.vverp.service.RoleService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import com.vverp.moli.util.*;
/**
* Controller - 角色
*
* @author
* @version 1.0
*/
@Controller("adminRoleController")
@RequestMapping("/admin/role")
public class RoleController extends BaseController {
@Resource
private RoleService roleService;
@RequestMapping(value = "/add")
public String add(ModelMap modelMap) {
modelMap.addAttribute("dataRanges", DataRange.values());
return "/role/add";
}
@RequestMapping(value = "/save")
public @ResponseBody
Message save(Role role) {
role.setIsSystem(false);
role.setAdmins(null);
roleService.save(role);
return SUCCESS;
}
@RequestMapping(value = "/edit")
public String edit(Long id, ModelMap model) {
Role role = roleService.find(id);
model.addAttribute("role", role);
model.addAttribute("authorities", role.getAuthorities());
model.addAttribute("tableColumnControlAuthorityList", role.getTableColumnControlAuthorityList());
model.addAttribute("dataRanges", DataRange.values());
return "/role/edit";
}
@RequestMapping(value = "/update")
@ResponseBody
public Message update(Role role) {
// if (!isValid(role)) {
// return Message.error("角色数据验证失败");
// }
Role pRole = roleService.find(role.getId());
if (pRole == null || pRole.getIsSystem()) {
return Message.error("角色数据验证失败");
}
if (pRole.getChineseName().equals("供应商") || pRole.getChineseName().equals("管理员")){
role.setChineseName(pRole.getChineseName());
}
roleService.update(role, "isSystem", "admins");
return SUCCESS;
}
@RequestMapping(value = "/list")
public String list(Pageable pageable, ModelMap model) {
model.addAttribute("page", roleService.findPage(pageable));
return "/role/list";
}
@RequestMapping("/view")
public String view(ModelMap modelMap, Long id) {
modelMap.addAttribute("role", roleService.find(id));
modelMap.addAttribute("authorities", roleService.find(id).getAuthorities());
modelMap.addAttribute("dataRanges", DataRange.values());
return "/role/view";
}
/**
* 删除
*/
@RequestMapping(value = "/delete")
public @ResponseBody
Message delete(Long[] ids) {
for (Long id : ids){
Role role = roleService.find(id);
if (role.getChineseName().equals("供应商")||role.getChineseName().equals("管理员")){
return Message.error("供应商或管理员无法删除");
}
}
roleService.delete(ids);
return SUCCESS;
}
@RequestMapping("/nameIsExist")
@ResponseBody
public boolean nameIsExist(String name) {
if (StringUtils.isEmpty(name)) {
return false;
} else {
return !roleService.nameIsExist(name);
}
}
@RequestMapping("/chineseNameIsExist")
@ResponseBody
public boolean chineseNameIsExist(String chineseName) {
if (StringUtils.isEmpty(chineseName)) {
return false;
} else {
return !roleService.chineseNameIsExist(chineseName);
}
}
}

View File

@@ -0,0 +1,95 @@
package com.vverp.controller.admin;
import com.vverp.entity.Material;
import com.vverp.entity.SizeStandard;
import com.vverp.moli.util.Message;
import com.vverp.moli.util.Page;
import com.vverp.moli.util.Pageable;
import com.vverp.moli.util.RespData;
import com.vverp.service.SizeStandardService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
@RequestMapping("admin/sizeStandard")
@Controller("adminSizeStandard")
public class SizeStandardController extends BaseController{
@Resource
private SizeStandardService sizeStandardService;
@RequestMapping("list")
public String list(ModelMap modelMap, Pageable pageable){
Page<SizeStandard> page = sizeStandardService.findPage(pageable);
modelMap.addAttribute("page",page);
return "sizeStandard/list";
}
@RequestMapping("add")
public String add(){
return "sizeStandard/add";
}
@RequestMapping("edit")
public String edit(ModelMap modelMap, Long id){
SizeStandard sizeStandard = sizeStandardService.find(id);
modelMap.addAttribute("sizeStandard",sizeStandard);
return "sizeStandard/edit";
}
@RequestMapping("save")
@ResponseBody
public RespData save(SizeStandard sizeStandard){
if (sizeStandardService.findByAttribute("name",sizeStandard.getName()) != null){
return RespData.error(sizeStandard.getName()+"已存在");
}
sizeStandardService.save(sizeStandard);
return RespData.success();
}
@RequestMapping("update")
@ResponseBody
public RespData update(SizeStandard sizeStandard){
SizeStandard source = sizeStandardService.findByAttribute("name",sizeStandard.getName());
if (source != null && !source.getId().equals(sizeStandard.getId())){
return RespData.error(sizeStandard.getName()+"已存在");
}
sizeStandardService.update(sizeStandard);
return RespData.success();
}
@RequestMapping("delete")
@ResponseBody
public Message delete(Long ids){
sizeStandardService.delete(ids);
return Message.success("删除成功");
}
/**
* 导入模板
*/
@RequestMapping("/exportTemplate")
public void exportTemplate(HttpServletResponse response) {
sizeStandardService.exportTemplate(response);
}
@RequestMapping("import")
@ResponseBody
public RespData importExcel(MultipartFile file) {
try {
sizeStandardService.importExcel(file);
return RespData.success();
} catch (RuntimeException e) {
return RespData.error(e.getMessage());
} catch (Exception e) {
return RespData.error("导入失败");
}
}
}

View File

@@ -0,0 +1,64 @@
package com.vverp.controller.admin;
import com.vverp.annotation.Module;
import com.vverp.entity.*;
import com.vverp.moli.util.RespData;
import com.vverp.service.SnPrefixService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.*;
/**
* @author dealsky
* @date 2020/3/11 8:38 下午
*/
@Controller("adminSnPrefixController")
@RequestMapping("/admin/snPrefix")
public class SnPrefixController extends BaseController {
@Resource
private SnPrefixService snPrefixService;
@RequestMapping("/list")
public String list(ModelMap modelMap) {
Class[] classes = new Class[]{PurchaseOrder.class, PurchaseStock.class};
List<Map<String, Object>> list = new ArrayList<>();
for (Class cls : classes) {
Map<String, Object> map = new HashMap<>();
String key = cls.getSimpleName();
Module module = (Module) cls.getAnnotation(Module.class);
if (module == null || StringUtils.isBlank(module.name())) {
continue;
}
map.put("moduleName", module.name());
map.put("name", key);
map.put("prefix", snPrefixService.get(key).getPrefix());
list.add(map);
}
modelMap.addAttribute("list", list);
return "snPrefix/list";
}
@RequestMapping("/dialog/edit")
public String dialogEdit(ModelMap modelMap, String name) {
SnPrefix snPrefix = snPrefixService.get(name);
modelMap.addAttribute("snPrefix", snPrefix);
return "/snPrefix/dialog/edit";
}
@RequestMapping("/update")
@ResponseBody
public RespData update(SnPrefix snPrefix) {
snPrefixService.updateSnPrefix(snPrefix);
return RespData.success();
}
}

View File

@@ -0,0 +1,142 @@
package com.vverp.controller.admin;
import cn.hutool.core.date.DateField;
import com.vverp.util.DateUtil;
import com.vverp.dto.OrderInfo;
import com.vverp.entity.*;
import com.vverp.enums.TransportType;
import com.vverp.moli.util.Filter;
import com.vverp.moli.util.Page;
import com.vverp.moli.util.Pageable;
import com.vverp.moli.util.RespData;
import com.vverp.service.*;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
@Controller("adminStatistics")
@RequestMapping("/admin/statistics")
public class StatisticsController extends BaseController {
@Resource
private PurchaseOrderService purchaseOrderService;
@Resource
private StatisticService statisticService;
@Resource
private PurchaseOrderItemService purchaseOrderItemService;
@Resource
private ProductService productService;
@Resource
private SupplierService supplierService;
@Resource
private PaymentAccountService paymentAccountService;
@Resource
private PaymentApplyService paymentApplyService;
@Resource
private MaterialOrderItemService materialOrderItemService;
@RequestMapping("/list")
@ResponseBody
public RespData list() {
Map<String, Object> map = new HashMap<>();
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_YEAR, -1);
Date endDate = calendar.getTime();
calendar.add(Calendar.MONTH, -1);
Date startDate = calendar.getTime();
List<Statistic> list = statisticService.analyze(Statistic.Period.day, startDate, endDate);
map.put("list", list);
return RespData.success(map);
}
/**
* 交易分析
*
* @return
*/
@RequestMapping("/business")
public String business() {
return "/statistics/business";
}
@RequestMapping("/businessData")
@ResponseBody
public RespData businessData(Date startDate, Date endDate) {
Map<String, Object> map = new HashMap<>();
OrderInfo purchaseInfo = purchaseOrderService.analyze(null, startDate, endDate);
map.put("purchaseCount", purchaseInfo.getCount());
map.put("purchaseAmount", purchaseInfo.getAmount());
return RespData.success(map);
}
/**
* 商品分析
*
* @return
*/
@RequestMapping("/product")
public String product() {
return "/statistics/product";
}
@RequestMapping("/home")
public String home() {
return "/statistics/home";
}
@RequestMapping("/homeData")
@ResponseBody
public RespData homeData(Date startDate, Date endDate) {
Map<String, Object> map = new HashMap<>();
OrderInfo applyInfo = materialOrderItemService.analyze(startDate, endDate);
OrderInfo purchaseInfo = purchaseOrderItemService.analyze(startDate, endDate);
map.put("applyCount", applyInfo.getNumber());
map.put("applyAmount", applyInfo.getAmount());
map.put("purchaseCount", purchaseInfo.getNumber());
map.put("purchaseAmount", purchaseInfo.getAmount());
map.put("list", purchaseOrderItemService.produceRankDTO(startDate, endDate, 10, null));
return RespData.success(map);
}
@RequestMapping("/productData")
@ResponseBody
public RespData productData(Date startDate, Date endDate) {
Map<String, Object> map = new HashMap<>();
OrderInfo applyInfo = materialOrderItemService.analyze(startDate, endDate);
OrderInfo purchaseInfo = purchaseOrderItemService.analyze(startDate, endDate);
map.put("applyCount", applyInfo.getNumber());
map.put("applyAmount", applyInfo.getAmount());
map.put("purchaseCount", purchaseInfo.getNumber());
map.put("purchaseAmount", purchaseInfo.getAmount());
map.put("list", materialOrderItemService.produceRankDTO(startDate, endDate, 10, null));
return RespData.success(map);
}
/**
* 资金曲线
*
* @return
*/
@RequestMapping("/moneyStatistic")
public String moneyStatistic() {
return "/statistics/moneyStatistic";
}
}

View File

@@ -0,0 +1,339 @@
package com.vverp.controller.admin;
import cn.hutool.json.JSONObject;
import com.vverp.base.Setting;
import com.vverp.dto.CompanyQuery;
import com.vverp.dto.OrderInfo;
import com.vverp.dto.OrderQuery;
import com.vverp.entity.*;
import com.vverp.enums.OrderStatus;
import com.vverp.moli.util.*;
import com.vverp.service.*;
import com.vverp.util.ZipUtil;
import org.bouncycastle.math.raw.Mod;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.ui.ModelMap;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.math.BigDecimal;
import java.util.*;
@Controller("adminSupplierController")
@RequestMapping("/admin/supplier")
public class SupplierController extends BaseController {
@Resource
private SupplierService supplierService;
@Resource
private PurchaseStockService purchaseStockService;
@Resource
private PaymentAccountService paymentAccountService;
@Resource
private PurchaseOrderService purchaseOrderService;
@Resource
private PurchaseStockItemService purchaseStockItemService;
@Resource
private PaymentApplyService paymentApplyService;
@Resource
private ProgressService progressService;
@Resource
private AdminService adminService;
@Resource
private AreaService areaService;
@RequestMapping("/list")
public String list(Pageable pageable, CompanyQuery companyQuery, ModelMap modelMap) {
Admin admin = adminService.getCurrent();
modelMap.addAttribute("progressId",companyQuery.getProgressId());
modelMap.addAttribute("progressList",progressService.findAll());
if (companyQuery.getProgressId() == null) {
companyQuery.setProgressId(admin.getNowProgress());
}
if (admin.getNowProgress() == null) {
modelMap.addAttribute("company",true);
}else {
modelMap.addAttribute("company",false);
}
Page<Supplier> page = supplierService.findPageView(pageable, companyQuery);
modelMap.addAttribute("page", page);
modelMap.addAttribute("createDateStart", companyQuery.getCreateDateStart());
modelMap.addAttribute("createDateEnd", companyQuery.getCreateDateEnd());
modelMap.addAttribute("sn", companyQuery.getSn());
modelMap.addAttribute("name", companyQuery.getName());
modelMap.addAttribute("address", companyQuery.getAddress());
modelMap.addAttribute("contact", companyQuery.getContact());
modelMap.addAttribute("phone", companyQuery.getPhone());
modelMap.addAttribute("landLinePhone", companyQuery.getLandLinePhone());
modelMap.addAttribute("memo", companyQuery.getMemo());
modelMap.addAttribute("email", companyQuery.getEmail());
modelMap.addAttribute("deliveryWay", companyQuery.getDeliveryWay());
modelMap.addAttribute("totalBalance", supplierService.sumBalance(companyQuery));
return "/supplier/list";
}
@RequestMapping("/statistics")
public String statistics(Pageable pageable, String name, Date startDate, Date endDate, ModelMap modelMap) {
CompanyQuery companyQuery = new CompanyQuery();
companyQuery.setName(name);
Page<Supplier> page = supplierService.findPageView(pageable, companyQuery);
OrderQuery orderQuery = new OrderQuery();
orderQuery.setCreateDateStart(startDate);
orderQuery.setCreateDateEnd(endDate);
List<Map<String, Object>> list = new ArrayList<>();
for (Supplier supplier : page.getContent()) {
Map<String, Object> map = new HashMap<>();
map.put("id", supplier.getId());
map.put("name", supplier.getName());
orderQuery.setOwnerId(supplier.getId());
// 单数
OrderInfo orderInfo = purchaseStockService.orderInfo(orderQuery);
map.put("orderCount", orderInfo.getCount());
// 金额
map.put("amount", orderInfo.getAmount());
// 总量
orderInfo = purchaseStockItemService.orderInfo(orderQuery);
map.put("count", orderInfo.getNumber());
list.add(map);
}
orderQuery.setOwnerId(null);
OrderInfo orderInfo = purchaseStockService.orderInfo(orderQuery);
modelMap.addAttribute("orderCount", orderInfo.getCount());
modelMap.addAttribute("amount", orderInfo.getAmount());
orderInfo = purchaseStockItemService.orderInfo(orderQuery);
modelMap.addAttribute("count", orderInfo.getAmount());
modelMap.addAttribute("page", new Page<>(list, page.getTotal(), page.getPageable()));
modelMap.addAttribute("name", companyQuery.getName());
modelMap.addAttribute("startDate", startDate);
modelMap.addAttribute("endDate", endDate);
return "/supplier/statistics";
}
@RequestMapping("/add")
public String add(ModelMap modelMap) {
Admin admin = adminService.getCurrent();
modelMap.addAttribute("progressList",progressService.findAll());
modelMap.addAttribute("progressId",admin.getNowProgress());
modelMap.addAttribute("provinceList", areaService.findProvinceList());
return "/supplier/add";
}
@RequestMapping(value = "/edit")
public String edit(Long id, ModelMap modelMap) {
Supplier supplier = supplierService.find(id);
modelMap.addAttribute("provinceList", areaService.findProvinceList());
modelMap.addAttribute("supplier", supplier);
modelMap.addAttribute("progressList",progressService.findAll());
modelMap.addAttribute("areaService", areaService);
return "/supplier/edit";
}
@RequestMapping(value = "/view")
public String view(Long id, ModelMap modelMap) {
Supplier supplier = supplierService.find(id);
modelMap.addAttribute("provinceList", areaService.findProvinceList());
modelMap.addAttribute("supplier", supplier);
modelMap.addAttribute("areaService", areaService);
return "/supplier/view";
}
@RequestMapping("/save")
@ResponseBody
public Message save(Supplier supplier,String username) {
// if (!isValid(supplier, BaseEntity.Save.class)) {
// return ERROR;
// }
try {
supplierService.saveSupplier(supplier,username);
return SUCCESS;
} catch (RuntimeException e) {
e.printStackTrace();
return Message.error(e.getMessage());
} catch (Exception e) {
e.printStackTrace();
return ERROR;
}
}
@RequestMapping("/update")
@ResponseBody
public Message update(Supplier supplier,String username) {
// if (!isValid(supplier, BaseEntity.Update.class)) {
// return ERROR;
// }
try {
supplierService.updateSupplier(supplier,username);
return SUCCESS;
} catch (RuntimeException e) {
return Message.error(e.getMessage());
} catch (Exception e) {
e.printStackTrace();
return ERROR;
}
}
@RequestMapping(value = "/delete", method = RequestMethod.POST)
@ResponseBody
public Message delete(Long[] ids) {
supplierService.webDelete(ids);
return SUCCESS;
}
/**
* 供应商付款
*/
@RequestMapping("/dialog/payment")
public String dialogPayment(ModelMap modelMap, Long id) {
Supplier supplier = supplierService.find(id);
modelMap.addAttribute("provinceList", areaService.findProvinceList());
modelMap.addAttribute("supplier", supplier);
OrderQuery orderQuery = new OrderQuery();
orderQuery.setStatus(OrderStatus.approved);
orderQuery.setOwnerId(id);
if (Setting.getData().getReceiptPoint().equals(SystemSetting.ReceiptPoint.order)) {
modelMap.addAttribute("list", purchaseOrderService.findList(orderQuery));
} else {
modelMap.addAttribute("list", purchaseStockService.findList(orderQuery));
}
modelMap.addAttribute("receiptPoint", Setting.getData().getReceiptPoint());
modelMap.addAttribute("paymentAccounts", paymentAccountService.findAll());
return "/supplier/dialog/payment";
}
/**
* 客户收款
*/
@RequestMapping("/payment")
@ResponseBody
public RespData payment(@RequestBody JSONObject jsonObject) {
try {
Supplier supplier = supplierService.find(jsonObject.getLong("supplierId"));
BigDecimal totalAmount = jsonObject.getBigDecimal("totalAmount");
Long accountId = jsonObject.getLong("account");
PaymentAccount paymentAccount = paymentAccountService.find(accountId);
for (Object o : jsonObject.getJSONArray("list")) {
JSONObject item = (JSONObject) o;
Long id = item.getLong("id");
BigDecimal amount = item.getBigDecimal("amount");
if (Setting.getData().getReceiptPoint().equals(SystemSetting.ReceiptPoint.order)) {
PurchaseOrder purchaseOrder = purchaseOrderService.find(id);
purchaseOrder.setPayedAmount(purchaseOrder.getPayedAmount().add(amount));
purchaseOrderService.update(purchaseOrder);
} else {
PurchaseStock purchaseStock = purchaseStockService.find(id);
purchaseStock.setPayedAmount(purchaseStock.getPayedAmount().add(amount));
purchaseStockService.update(purchaseStock);
}
}
supplierService.payment(supplier, totalAmount, null, paymentAccount);
return RespData.success();
} catch (Exception e) {
e.printStackTrace();
return RespData.error("操作失败");
}
}
/**
* 采购应付
*/
@RequestMapping("/purchasePayment")
public String purchasePayment(ModelMap modelMap, Pageable pageable) {
pageable.setFilters(Collections.singletonList(Filter.gt("balance", 0)));
Page<Supplier> page = supplierService.findPage(pageable);
modelMap.addAttribute("page", page);
return "/supplier/purchasePayment";
}
/**
* 导出
*/
@RequestMapping("/export")
public void export(HttpServletResponse response, CompanyQuery companyQuery) {
Admin admin = adminService.getCurrent();
companyQuery.setProgressId(admin.getNowProgress());
supplierService.export(response, companyQuery);
}
/**
* 导入模板
*/
@RequestMapping("/exportTemplate")
public void exportTemplate(HttpServletResponse response) {
supplierService.exportTemplate(response);
}
@RequestMapping("dialog/addFile")
public String addFile(ModelMap modelMap){
modelMap.addAttribute("progressId",adminService.getCurrent().getNowProgress());
return "supplier/dialog/addFile";
}
@RequestMapping("/import")
@ResponseBody
public RespData importExcel(MultipartFile file,Long progressId) {
try {
supplierService.importExcel(file,progressId);
return RespData.success();
} catch (Exception e) {
e.printStackTrace();
return RespData.error(e.getMessage());
}
}
@RequestMapping("/dialog/detail")
public String dialogDetail(ModelMap modelMap, Long id) {
Supplier supplier = supplierService.find(id);
modelMap.addAttribute("supplier", supplier);
List<PurchaseOrder> contractList = purchaseOrderService.findList(null, Collections.singletonList(
Filter.eq("ownerId", supplier.getId())
), null);
List<PaymentApply> paymentApplyList = paymentApplyService.findList(null, Arrays.asList(
Filter.eq("type", PaymentApply.Type.purchaseOrder),
Filter.eq("ownerId", supplier.getId()),
Filter.eq("receivePayment", PaymentApply.ReceivePayment.payment)
), null);
List<PaymentApply> refundApplyList = paymentApplyService.findList(null, Arrays.asList(
Filter.eq("type", PaymentApply.Type.purchaseOrder),
Filter.eq("ownerId", supplier.getId()),
Filter.eq("receivePayment", PaymentApply.ReceivePayment.receive)
), null);
modelMap.addAttribute("contractList", contractList);
modelMap.addAttribute("paymentApplyList", paymentApplyList);
modelMap.addAttribute("refundApplyList", refundApplyList);
return "/supplier/dialog/detail";
}
@RequestMapping("dialog/loadZip")
public String dialogLoadZip(ModelMap modelMap){
modelMap.addAttribute("progressId",adminService.getCurrent().getNowProgress());
return "supplier/dialog/loadZip";
}
@RequestMapping(value = "/loadZip",method = RequestMethod.POST)
@ResponseBody
public RespData loadZip(@RequestParam("file") MultipartFile file,Long progressId){
supplierService.loadZip(file,progressId);
return RespData.success();
}
}

View File

@@ -0,0 +1,116 @@
package com.vverp.controller.admin;
import com.google.common.base.Suppliers;
import com.vverp.dto.CompanyQuery;
import com.vverp.entity.Admin;
import com.vverp.entity.Supplier;
import com.vverp.entity.SupplierEvaluate;
import com.vverp.entity.SystemSetting;
import com.vverp.moli.util.Message;
import com.vverp.moli.util.Page;
import com.vverp.moli.util.Pageable;
import com.vverp.moli.util.RespData;
import com.vverp.service.AdminService;
import com.vverp.service.SupplierEvaluateService;
import com.vverp.service.SupplierService;
import com.vverp.service.SystemSettingService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
@RequestMapping("admin/supplierEvaluate")
@Controller("adminSupplierEvaluate")
public class SupplierEvaluateController extends BaseController{
@Resource
private SupplierEvaluateService supplierEvaluateService;
@Resource
private SupplierService supplierService;
@Resource
private AdminService adminService;
@Resource
private SystemSettingService systemSettingService;
@RequestMapping("list")
public String list(ModelMap modelMap, Pageable pageable){
Page<SupplierEvaluate> page = supplierEvaluateService.findPage(pageable);
modelMap.addAttribute("page",page);
return "supplierEvaluate/list";
}
@RequestMapping("add")
public String add(ModelMap modelMap){
Admin admin = adminService.getCurrent();
CompanyQuery companyQuery = new CompanyQuery();
companyQuery.setProgressId(admin.getNowProgress());
modelMap.addAttribute("supplierList",supplierService.findList(companyQuery));
return "supplierEvaluate/add";
}
@RequestMapping("dialog/weight")
public String dialogWeight(ModelMap modelMap){
SystemSetting systemSetting = systemSettingService.findSingle();
modelMap.addAttribute("speedWeight",systemSetting.getSpeedWeight());
modelMap.addAttribute("qualityWeight",systemSetting.getQualityWeight());
modelMap.addAttribute("warrantyWeight",systemSetting.getWarrantyWeight());
return "supplierEvaluate/dialog/weight";
}
@RequestMapping("edit")
public String edit(ModelMap modelMap,Long id){
SupplierEvaluate supplierEvaluate = supplierEvaluateService.find(id);
modelMap.addAttribute("supplierEvaluate",supplierEvaluate);
Admin admin = adminService.getCurrent();
CompanyQuery companyQuery = new CompanyQuery();
companyQuery.setProgressId(admin.getNowProgress());
modelMap.addAttribute("supplierList",supplierService.findList(companyQuery));
return "supplierEvaluate/edit";
}
@RequestMapping("save")
@ResponseBody
public Message save(SupplierEvaluate supplierEvaluate){
if (supplierEvaluate.getSupplier() == null || supplierEvaluate.getSupplier().getId() == null){
return Message.error("供应商不能为空");
}
Supplier supplier = supplierService.find(supplierEvaluate.getSupplier().getId());
supplierEvaluate.setSupplier(supplier);
supplierEvaluateService.save(supplierEvaluate);
return Message.success("保存成功");
}
@RequestMapping("update")
@ResponseBody
public Message update(SupplierEvaluate supplierEvaluate){
if (supplierEvaluate.getSupplier() == null || supplierEvaluate.getSupplier().getId() == null){
return Message.error("供应商不能为空");
}
Supplier supplier = supplierService.find(supplierEvaluate.getSupplier().getId());
supplierEvaluate.setSupplier(supplier);
supplierEvaluateService.update(supplierEvaluate);
return Message.success("保存成功");
}
@RequestMapping("delete")
@ResponseBody
public Message delete(Long ids){
supplierEvaluateService.delete(ids);
return Message.success("删除成功");
}
@RequestMapping("saveWeight")
@ResponseBody
public RespData saveWeight(BigDecimal speedWeight,BigDecimal qualityWeight,BigDecimal warrantyWeight){
SystemSetting systemSetting = systemSettingService.findSingle();
systemSetting.setQualityWeight(qualityWeight);
systemSetting.setSpeedWeight(speedWeight);
systemSetting.setWarrantyWeight(warrantyWeight);
systemSettingService.update(systemSetting);
return RespData.success("保存成功");
}
}

View File

@@ -0,0 +1,279 @@
package com.vverp.controller.admin;
import com.google.common.base.Suppliers;
import com.vverp.entity.*;
import com.vverp.moli.util.Message;
import com.vverp.moli.util.Page;
import com.vverp.moli.util.Pageable;
import com.vverp.moli.util.RespData;
import com.vverp.service.*;
import org.bouncycastle.math.raw.Mod;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RequestMapping("admin/supplierProduct")
@Controller("adminSupplierProduct")
public class SupplierProductController extends BaseController{
@Resource
private SupplierProductService supplierProductService;
@Resource
private SupplierService supplierService;
@Resource
private ProductTypeService productTypeService;
@Resource
private DiameterService diameterService;
@Resource
private WallThicknessService wallThicknessService;
@Resource
private MaterialService materialService;
@Resource
private SizeStandardService sizeStandardService;
@Resource
private EndFaceService endFaceService;
@Resource
private PressureLevelService pressureLevelService;
@Resource
private AdminService adminService;
@RequestMapping("list")
public String list(ModelMap modelMap, Long supplierId, Pageable pageable, String productTypeChan,String bigType,String smallType,String supplierName){
Admin admin = adminService.getCurrent();
for (Supplier findSupplier : admin.getSupplierList()){
if (admin.getNowProgress()==null){
if (findSupplier.getProgressId() == null){
supplierId = findSupplier.getId();
}
}else {
if (admin.getNowProgress().equals(findSupplier.getProgressId())){
supplierId = findSupplier.getId();
}
}
}
// if (admin.getSupplier() != null){
// supplierId = admin.getSupplier().getId();
// }
Page<SupplierProduct> page = supplierProductService.findPageView(supplierId,pageable,productTypeChan,admin.getNowProgress(),bigType,smallType,supplierName);
// Map<Long,String> typeChan = new HashMap<>();
// for (SupplierProduct product : page.getContent()){
// if (product.getProductType() != null) {
// if (product.getProductType().getParentId() != null){
// ProductType parent = productTypeService.find(product.getProductType().getParentId());
// typeChan.put(product.getId(), parent.getName()+"/"+product.getProductType().getName());
// }else {
// typeChan.put(product.getId(), product.getProductType().getName());
// }
// }else {
// typeChan.put(product.getId(), "");
// }
// }
modelMap.addAttribute("page",page);
// modelMap.addAttribute("typeChan",typeChan);
modelMap.addAttribute("supplierId",supplierId);
modelMap.addAttribute("bigType",bigType);
modelMap.addAttribute("smallType",smallType);
modelMap.addAttribute("supplierName",supplierName);
Supplier supplier = supplierService.find(supplierId);
// modelMap.addAttribute("supplierName",supplier.getName());
modelMap.addAttribute("productTypeChan",productTypeChan);
return "supplierProduct/list";
}
@RequestMapping("add")
public String add(Long supplierId,ModelMap modelMap){
Supplier supplier = supplierService.find(supplierId);
Admin admin = adminService.getCurrent();
Supplier adminSupplier = null;
for (Supplier findSupplier : admin.getSupplierList()){
if (admin.getNowProgress()==null){
if (findSupplier.getProgressId() == null){
adminSupplier = findSupplier;
}
}else {
if (admin.getNowProgress().equals(findSupplier.getProgressId())){
adminSupplier = findSupplier;
}
}
}
// if (admin.getSupplier() != null){
if (adminSupplier != null){
List<Supplier> list = new ArrayList<>();
list.add(adminSupplier);
modelMap.addAttribute("supplierList",list);
modelMap.addAttribute("supplier",supplier);
modelMap.addAttribute("supplierId",supplier.getId());
}else {
modelMap.addAttribute("supplier",supplier);
modelMap.addAttribute("supplierId",supplier==null?null:supplier.getId());
modelMap.addAttribute("supplierList",supplierService.findListByAttribute("progressId",admin.getNowProgress()));
}
modelMap.addAttribute("productTypeList",productTypeService.findListByAttribute("level",1));
modelMap.addAttribute("pressureLevelList",pressureLevelService.findAll());
modelMap.addAttribute("endFaceList",endFaceService.findAll());
modelMap.addAttribute("materialList",materialService.findAll());
modelMap.addAttribute("wallThicknessList",wallThicknessService.findAll());
modelMap.addAttribute("diameterList",diameterService.findAll());
modelMap.addAttribute("sizeStandardList",sizeStandardService.findAll());
return "supplierProduct/add";
}
@RequestMapping("edit")
public String edit(Long id,ModelMap modelMap){
Admin admin = adminService.getCurrent();
Supplier adminSupplier = null;
for (Supplier findSupplier : admin.getSupplierList()){
if (admin.getNowProgress()==null){
if (findSupplier.getProgressId() == null){
adminSupplier = findSupplier;
}
}else {
if (admin.getNowProgress().equals(findSupplier.getProgressId())){
adminSupplier = findSupplier;
}
}
}
// if (admin.getSupplier() != null){
if (adminSupplier != null){
List<Supplier> list = new ArrayList<>();
list.add(adminSupplier);
modelMap.addAttribute("supplierList",list);
}else {
modelMap.addAttribute("supplierList",supplierService.findListByAttribute("progressId",admin.getNowProgress()));
}
SupplierProduct supplierProduct = supplierProductService.find(id);
ProductType productType = productTypeService.find(supplierProduct.getBigTypeId());
modelMap.addAttribute("bigTypeList",productTypeService.findListByAttribute("level",1));
if (productType != null) {
modelMap.addAttribute("smallTypeList", productTypeService.findByParent(productType.getId()));
}else {
modelMap.addAttribute("smallTypeList", new ArrayList<>());
}
modelMap.addAttribute("supplierProduct",supplierProduct);
modelMap.addAttribute("pressureLevelList",pressureLevelService.findAll());
modelMap.addAttribute("endFaceList",endFaceService.findAll());
modelMap.addAttribute("materialList",materialService.findAll());
modelMap.addAttribute("wallThicknessList",wallThicknessService.findAll());
modelMap.addAttribute("diameterList",diameterService.findAll());
modelMap.addAttribute("sizeStandardList",sizeStandardService.findAll());
return "supplierProduct/edit";
}
@RequestMapping("save")
@ResponseBody
public Message save(SupplierProduct supplierProduct,Long supplierId){
try {
if (supplierProduct.getSmallTypeId() != null){
ProductType productType = productTypeService.find(supplierProduct.getSmallTypeId());
supplierProduct.setProductType(productType);
}else {
ProductType productType = productTypeService.find(supplierProduct.getBigTypeId());
supplierProduct.setProductType(productType);
}
supplierProductService.saveEntity(supplierProduct,supplierId);
return Message.success("保存成功");
}catch (Exception e){
e.printStackTrace();
return Message.error(e.getMessage());
}
}
@RequestMapping("update")
@ResponseBody
public Message update(SupplierProduct supplierProduct,Long supplierId){
try {
if (supplierProduct.getSmallTypeId() != null){
ProductType productType = productTypeService.find(supplierProduct.getSmallTypeId());
supplierProduct.setProductType(productType);
}else {
ProductType productType = productTypeService.find(supplierProduct.getBigTypeId());
supplierProduct.setProductType(productType);
}
supplierProductService.updateEntity(supplierProduct,supplierId);
return Message.success("保存成功");
}catch (Exception e){
e.printStackTrace();
return Message.error(e.getMessage());
}
}
@RequestMapping("delete")
@ResponseBody
public Message delete(Long[] ids){
supplierProductService.delete(ids);
return Message.success("删除成功");
}
@RequestMapping("dialog/addFile")
public String dialogAddFile(ModelMap modelMap){
Admin admin =adminService.getCurrent();
modelMap.addAttribute("progressId",admin.getNowProgress());
return "supplierProduct/dialog/addFile";
}
@RequestMapping(value = "/uploadExcel")
@ResponseBody
public RespData uploadExcel(MultipartFile file,Long progressId) {
if (file == null) {
return RespData.error("文件为空");
}
//获得文件名
String fileName = file.getOriginalFilename();
//判断文件是否是excel文件
if (!fileName.endsWith("xls") && !fileName.endsWith("xlsx")) {
return RespData.error("不是excel文件");
}
try {
Map<String,Object> map = supplierProductService.saveFile(file,progressId);
List list = (List) map.get("list");
Integer repeatNum = Integer.valueOf(map.get("repeatNum").toString());
Integer failNum = Integer.valueOf(map.get("failNum").toString());
String message = "导入成功,"+repeatNum+"条已存在";
map.put("msg",message);
if (failNum == 0 && repeatNum ==0){
return RespData.success(map);
}
if (failNum>0) {
message = failNum + "条导入失败";
}
map.put("msg",message);
return RespData.warn(map);
}catch (Exception e){
e.printStackTrace();
return RespData.error(e.getMessage());
}
}
@RequestMapping("uploadResult")
public String uploadResult(ModelMap modelMap,Integer successNum, Integer repeatNum, Integer failNum, String key){
modelMap.addAttribute("successNum",successNum);
modelMap.addAttribute("repeatNum",repeatNum);
modelMap.addAttribute("failNum",failNum);
modelMap.addAttribute("key", key);
return "supplierProduct/dialog/uploadResult";
}
@RequestMapping("exportNotFund")
public void exportNotFund(HttpServletResponse response, String key) {
try {
supplierProductService.exportNotFund(response, key);
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,110 @@
package com.vverp.controller.admin;
import com.vverp.base.Setting;
import com.vverp.dto.OrderCalendar;
import com.vverp.entity.*;
import com.vverp.moli.util.Filter;
import com.vverp.moli.util.RespData;
import com.vverp.service.*;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.*;
/**
* @author dealsky
* @date 2020/2/13 8:54 下午
*/
@Controller
@RequestMapping("/admin/system")
public class SystemController extends BaseController {
@Resource
private SystemSettingService systemSettingService;
@Resource
private PurchaseOrderService purchaseOrderService;
@Resource
private PaymentMethodService paymentMethodService;
@RequestMapping("/setting")
public String setting(ModelMap modelMap) {
modelMap.addAttribute("systemSetting", systemSettingService.findSingle());
return "/system/setting";
}
@RequestMapping("/theme")
public String theme(ModelMap modelMap) {
modelMap.addAttribute("navigateModes", SystemSetting.NavigateMode.values());
modelMap.addAttribute("themeSchemes", SystemSetting.ThemeScheme.values());
modelMap.addAttribute("systemSetting", systemSettingService.findSingle());
return "/system/theme";
}
@RequestMapping("/update")
@ResponseBody
public RespData update(SystemSetting systemSetting) {
try {
systemSettingService.updateSystemSetting(systemSetting);
return RespData.success("更新成功");
} catch (Exception e) {
e.printStackTrace();
return RespData.error("更新失败");
}
}
@RequestMapping("/themeUpdate")
@ResponseBody
public RespData themeUpdate(SystemSetting systemSetting) {
try {
systemSettingService.themeUpdate(systemSetting);
return RespData.success("更新成功");
} catch (Exception e) {
e.printStackTrace();
return RespData.error("更新失败");
}
}
@RequestMapping("/selectReceiptPoint")
public String selectReceiptPoint() {
return "/common/dialog/selectReceiptPoint";
}
@RequestMapping("/setReceiptPoint")
@ResponseBody
public RespData setReceiptPoint(SystemSetting.ReceiptPoint receiptPoint) {
SystemSetting systemSetting = systemSettingService.findSingle();
systemSetting.setReceiptPoint(receiptPoint);
systemSettingService.update(systemSetting);
Setting.load(systemSetting);
return RespData.success();
}
@RequestMapping("/calendar")
public String calendar() {
return "/system/calendar";
}
@RequestMapping("/calendarData")
@ResponseBody
public RespData calendarData() {
Map<String, Object> map = new HashMap<>();
List<PurchaseOrder> purchaseOrderList = purchaseOrderService.findList(null, Collections.singletonList(Filter.isNotNull("paymentMethodId")), null);
List<OrderCalendar> purchaseOrders = new ArrayList<>();
for (PurchaseOrder purchaseOrder : purchaseOrderList) {
PaymentMethod paymentMethod = paymentMethodService.find(purchaseOrder.getPaymentMethodId());
if (paymentMethod != null) {
for (PaymentMethodItem item : paymentMethod.getPaymentMethodItemList()) {
purchaseOrders.add(new OrderCalendar(item.getId(), purchaseOrder.getSn(), item.getDate()));
}
}
}
map.put("purchaseOrders", purchaseOrders);
return RespData.success(map);
}
}

View File

@@ -0,0 +1,76 @@
package com.vverp.controller.admin;
import com.vverp.entity.TableStorage;
import com.vverp.moli.util.RespData;
import com.vverp.service.TableStorageService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author dealsky
*/
@Controller
@RequestMapping("/tableStorage")
public class TableStorageController extends BaseController {
@Resource
private TableStorageService tableStorageService;
@RequestMapping("/getByName")
@ResponseBody
public RespData getColumns(String name, Boolean fieldControl) {
TableStorage tableStorage = tableStorageService.findByName(name);
Map<String, Object> data = new HashMap<>();
if (fieldControl != null && fieldControl) {
List<String> invalidFieldList= tableStorageService.getInvalidFieldList(name);
Map<String, Object> value = new HashMap<>();
if (tableStorage != null) {
value.put("name", tableStorage.getName());
value.put("content", tableStorage.getContent());
value.put("invalidFieldList", invalidFieldList);
data.put("value", value);
return RespData.success(data);
}
}
data.put("value", tableStorage);
return RespData.success(data);
}
@RequestMapping("/fieldControl/getByName")
@ResponseBody
public RespData fieldControlGetByName(String name, Long roleId) {
Map<String, Object> data = new HashMap<>();
data.put("value", tableStorageService.fieldControlGetByName(name, roleId));
return RespData.success(data);
}
@RequestMapping("/save")
@ResponseBody
public RespData save(String name, String content) {
try {
TableStorage tableStorage = tableStorageService.findByName(name);
if (tableStorage == null) {
tableStorage = new TableStorage();
tableStorage.setName(name);
tableStorage.setContent(content);
tableStorageService.save(tableStorage);
} else {
tableStorage.setContent(content);
tableStorageService.update(tableStorage);
}
return RespData.success();
} catch (Exception e) {
e.printStackTrace();
return RespData.error("出错了");
}
}
}

View File

@@ -0,0 +1,103 @@
package com.vverp.controller.admin;
import com.vverp.entity.Admin;
import com.vverp.entity.UseOrder;
import com.vverp.moli.util.Message;
import com.vverp.moli.util.Page;
import com.vverp.moli.util.Pageable;
import com.vverp.moli.util.RespData;
import com.vverp.service.AdminService;
import com.vverp.service.ProductService;
import com.vverp.service.UseOrderService;
import com.vverp.util.GetDateUtil;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.Date;
@RequestMapping("admin/useOrder")
@Controller("adminUseOrder")
public class UseOrderController extends BaseController{
@Resource
private UseOrderService useOrderService;
@Resource
private ProductService productService;
@Resource
private AdminService adminService;
@RequestMapping("/list")
public String list(ModelMap modelMap, Pageable pageable, String sn, Date createDateStart, Date createDateEnd, Long adminId) {
if (createDateEnd != null) {
createDateEnd = GetDateUtil.getDayEndTime(createDateEnd);
}
Admin admin = adminService.getCurrent();
Page<UseOrder> page = useOrderService.findPageView(pageable, sn, createDateStart, createDateEnd, adminId,admin.getNowProgress());
modelMap.addAttribute("page", page);
modelMap.addAttribute("sn", sn);
modelMap.addAttribute("createDateStart", createDateStart);
modelMap.addAttribute("createDateEnd", createDateEnd);
return "/useOrder/list";
}
@RequestMapping("add")
public String add(ModelMap modelMap){
modelMap.addAttribute("adminList",adminService.findAll());
return "useOrder/add";
}
@RequestMapping("edit")
public String edit(ModelMap modelMap, Long id){
UseOrder useOrder = useOrderService.find(id);
modelMap.addAttribute("adminList",adminService.findAll());
modelMap.addAttribute("useOrder",useOrder);
return "useOrder/edit";
}
@RequestMapping("view")
public String view(ModelMap modelMap, Long id){
UseOrder useOrder = useOrderService.find(id);
modelMap.addAttribute("useOrder",useOrder);
return "useOrder/view";
}
@RequestMapping("save")
@ResponseBody
public RespData save(UseOrder useOrder){
useOrderService.saveUseOrder(useOrder);
return RespData.success();
}
@RequestMapping("update")
@ResponseBody
public RespData update(UseOrder useOrder){
useOrderService.updateUseOrder(useOrder);
return RespData.success();
}
@RequestMapping("delete")
@ResponseBody
public Message delete(Long ids){
UseOrder useOrder = useOrderService.find(ids);
if (useOrder.getStockConfirm()){
return Message.error("已确认,无法删除");
}else {
useOrderService.delete(ids);
}
return Message.success("删除成功");
}
@RequestMapping("confirm")
@ResponseBody
public RespData save(Long id){
try{
useOrderService.confirmOrder(id);
}catch (Exception e){
return RespData.error(e.getMessage());
}
return RespData.success();
}
}

View File

@@ -0,0 +1,94 @@
package com.vverp.controller.admin;
import com.vverp.entity.Diameter;
import com.vverp.entity.WallThickness;
import com.vverp.moli.util.Message;
import com.vverp.moli.util.Page;
import com.vverp.moli.util.Pageable;
import com.vverp.moli.util.RespData;
import com.vverp.service.WallThicknessService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
@RequestMapping("admin/wallThickness")
@Controller("adminWallThickness")
public class WallThicknessController extends BaseController{
@Resource
private WallThicknessService wallThicknessService;
@RequestMapping("list")
public String list(ModelMap modelMap, Pageable pageable){
Page<WallThickness> page = wallThicknessService.findPage(pageable);
modelMap.addAttribute("page",page);
return "wallThickness/list";
}
@RequestMapping("add")
public String add(){
return "wallThickness/add";
}
@RequestMapping("edit")
public String edit(ModelMap modelMap, Long id){
WallThickness wallThickness = wallThicknessService.find(id);
modelMap.addAttribute("wallThickness",wallThickness);
return "wallThickness/edit";
}
@RequestMapping("save")
@ResponseBody
public RespData save(WallThickness wallThickness){
if (wallThicknessService.findByAttribute("name",wallThickness.getName()) != null){
return RespData.error(wallThickness.getName()+"已存在");
}
wallThicknessService.save(wallThickness);
return RespData.success();
}
@RequestMapping("update")
@ResponseBody
public RespData update(WallThickness wallThickness){
WallThickness source = wallThicknessService.findByAttribute("name",wallThickness.getName());
if (source != null && !source.getId().equals(wallThickness.getId())){
return RespData.error(wallThickness.getName()+"已存在");
}
wallThicknessService.update(wallThickness);
return RespData.success();
}
@RequestMapping("delete")
@ResponseBody
public Message delete(Long ids){
wallThicknessService.delete(ids);
return Message.success("删除成功");
}
/**
* 导入模板
*/
@RequestMapping("/exportTemplate")
public void exportTemplate(HttpServletResponse response) {
wallThicknessService.exportTemplate(response);
}
@RequestMapping("import")
@ResponseBody
public RespData importExcel(MultipartFile file) {
try {
wallThicknessService.importExcel(file);
return RespData.success();
} catch (RuntimeException e) {
return RespData.error(e.getMessage());
} catch (Exception e) {
return RespData.error("导入失败");
}
}
}