diff --git a/src/main/java/com/huaheng/api/general/controller/BasicDataApi.java b/src/main/java/com/huaheng/api/general/controller/BasicDataApi.java new file mode 100644 index 0000000..90aafdc --- /dev/null +++ b/src/main/java/com/huaheng/api/general/controller/BasicDataApi.java @@ -0,0 +1,123 @@ +package com.huaheng.api.general.controller; + +import com.huaheng.api.general.service.BasicDataApiService; +import com.huaheng.framework.aspectj.lang.annotation.Log; +import com.huaheng.framework.aspectj.lang.constant.BusinessType; +import com.huaheng.framework.web.controller.BaseController; +import com.huaheng.framework.web.domain.AjaxResult; +import com.huaheng.pc.config.customer.domain.Customer; +import com.huaheng.pc.config.material.domain.Material; +import com.huaheng.pc.config.supplier.domain.Supplier; +import com.huaheng.pc.config.warehouse.domain.Warehouse; +import com.huaheng.pc.system.dept.domain.Dept; +import com.huaheng.pc.system.dict.domain.DictData; +import com.huaheng.pc.system.user.domain.User; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("/api/basicData") +@Api(tags = {"basicData"}, description = "基础数据接口") +public class BasicDataApi extends BaseController { + + @Autowired + private BasicDataApiService basicDataApiService; + + /** + * 同步物料 + */ + @Log(title = "物料添加", action = BusinessType.INSERT) + @PostMapping("/material") + @ApiOperation("物料添加公共接口") + @ResponseBody + public AjaxResult MaterialApi(@RequestBody Material material) + { + AjaxResult ajaxResult = basicDataApiService.material(material); + return ajaxResult; + } + + /** + * 同步字典 + */ + @Log(title = "字典添加", action = BusinessType.INSERT) + @PostMapping("/dictData") + @ApiOperation("字典添加公共接口") + @ResponseBody + public AjaxResult UnitlApi(@RequestBody DictData dictData) + { + AjaxResult ajaxResult = basicDataApiService.dict(dictData); + return ajaxResult; + } + + + + /** + * 同步仓库和货主 + */ + @Log(title = "仓库添加", action = BusinessType.INSERT) + @PostMapping("/warehouse") + @ApiOperation("仓库添加公共接口") + @ResponseBody + public AjaxResult WarehouseApi(@RequestBody Warehouse warehouse) + { + AjaxResult ajaxResult = basicDataApiService.warehouse(warehouse); + return ajaxResult; + } + + /** + * 同步客户档案 + */ + @Log(title = "客户档案添加", action = BusinessType.INSERT) + @PostMapping("/customer") + @ApiOperation("客户档案添加公共接口") + @ResponseBody + public AjaxResult CustomerApi(@RequestBody Customer customer) + { + AjaxResult ajaxResult = basicDataApiService.customer(customer); + return ajaxResult; + } + + /** + * 同步部门档案 + */ + @Log(title = "部门档案添加", action = BusinessType.INSERT) + @PostMapping("/dept") + @ApiOperation("部门档案添加公共接口") + @ResponseBody + public AjaxResult DeptApi(@RequestBody Dept dept) + { + AjaxResult ajaxResult = basicDataApiService.dept(dept); + return ajaxResult; + } + + /** + * 同步人员档案 + */ + @Log(title = "人员档案添加", action = BusinessType.INSERT) + @PostMapping("/user") + @ApiOperation("人员档案添加公共接口") + @ResponseBody + public AjaxResult UserApi(@RequestBody User user) + { + AjaxResult ajaxResult = basicDataApiService.user(user); + return ajaxResult; + } + + /** + * 同步供应商档案 + */ + @Log(title = "供应商档案添加", action = BusinessType.INSERT) + @PostMapping("/supplier") + @ApiOperation("供应商档案添加公共接口") + @ResponseBody + public AjaxResult SupplierApi(@RequestBody Supplier supplier){ + AjaxResult ajaxResult = basicDataApiService.supplier(supplier); + return ajaxResult; + } + + + + +} diff --git a/src/main/java/com/huaheng/api/general/controller/LoginApi.java b/src/main/java/com/huaheng/api/general/controller/LoginApi.java new file mode 100644 index 0000000..38dba14 --- /dev/null +++ b/src/main/java/com/huaheng/api/general/controller/LoginApi.java @@ -0,0 +1,54 @@ +package com.huaheng.api.general.controller; + +import com.alibaba.fastjson.JSONException; +import com.huaheng.common.utils.DataUtils; +import com.huaheng.framework.web.controller.BaseController; +import com.huaheng.framework.web.domain.AjaxResult; +import com.huaheng.pc.system.user.service.IUserService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + + +@RestController +@RequestMapping("/api") +@Api(tags = {"Login"}, description = "登陆接口") +public class LoginApi extends BaseController { + + @Autowired + private IUserService userService; + + @PostMapping("/login") + @ApiOperation("登陆接口") + public AjaxResult login(@RequestBody @ApiParam(value="登陆的Map集合") Map<String, String> param) + { + if (param.get("username") == null) + throw new JSONException("username(用户名)不能为空"); + if (param.get("password") == null) + throw new JSONException("password(密码)不能为空"); + if (param.get("warehouseCode") == null) + throw new JSONException("warehouseCode(仓库编码)不能为空"); + String username = param.get("username"); + String password = param.get("password"); + String warehouseCode = param.get("warehouseCode"); + AjaxResult ajaxResult = userService.login(username, password, warehouseCode, false); + return ajaxResult; + } + + + @PostMapping("/heartbeat") + @ApiOperation("心跳接口,用于延长cookie有效期") + public AjaxResult heartbeat() + { + return AjaxResult.success("success"); + } + + +} diff --git a/src/main/java/com/huaheng/api/general/service/BasicDataApiService.java b/src/main/java/com/huaheng/api/general/service/BasicDataApiService.java new file mode 100644 index 0000000..16920ea --- /dev/null +++ b/src/main/java/com/huaheng/api/general/service/BasicDataApiService.java @@ -0,0 +1,510 @@ +package com.huaheng.api.general.service; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.huaheng.common.exception.service.ServiceException; +import com.huaheng.common.utils.StringUtils; +import com.huaheng.framework.web.domain.AjaxResult; +import com.huaheng.pc.config.company.domain.Company; +import com.huaheng.pc.config.company.service.CompanyService; +import com.huaheng.pc.config.customer.domain.Customer; +import com.huaheng.pc.config.customer.service.CustomerServiceImpl; +import com.huaheng.pc.config.material.domain.Material; +import com.huaheng.pc.config.material.service.MaterialService; +import com.huaheng.pc.config.supplier.domain.Supplier; +import com.huaheng.pc.config.supplier.service.SupplierService; +import com.huaheng.pc.config.warehouse.domain.Warehouse; +import com.huaheng.pc.config.warehouse.service.WarehouseService; +import com.huaheng.pc.system.dept.domain.Dept; +import com.huaheng.pc.system.dept.service.IDeptService; +import com.huaheng.pc.system.dict.domain.DictData; +import com.huaheng.pc.system.dict.domain.DictType; +import com.huaheng.pc.system.dict.mapper.DictDataMapper; +import com.huaheng.pc.system.dict.mapper.DictTypeMapper; +import com.huaheng.pc.system.dict.service.IDictDataService; +import com.huaheng.pc.system.dict.service.IDictTypeService; +import com.huaheng.pc.system.user.domain.User; +import com.huaheng.pc.system.user.service.IUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; + +@Component +@Transactional +public class BasicDataApiService { + @Autowired + IDictTypeService dictTypeService; + @Autowired + IDictDataService dictDataService; + @Autowired + MaterialService materialService; + + @Resource + private DictTypeMapper dictTypeMapper; + @Resource + private DictDataMapper dictDataMapper; + + @Autowired + IUserService iUserService; + + @Autowired + IDeptService iDeptService; + + @Autowired + CustomerServiceImpl iCustomerService; + + @Autowired + WarehouseService iWarehouseService; + + @Autowired + SupplierService iSupplierService; + + @Autowired + CompanyService companyService; + + //检查仓库 + public Warehouse checkWarehouse(String code) { + LambdaQueryWrapper<Warehouse> warehouseLam = Wrappers.lambdaQuery(); + warehouseLam.eq(Warehouse::getCode, code); + Warehouse warehouse = iWarehouseService.getOne(warehouseLam); + if (warehouse == null) { + throw new ServiceException("数据出现问题,系统没有该仓库"); + } + return warehouse; + } + + /** + * 字典通用接口 + * 1、判断必填字段是否为空 + * 2、仓库是否正确 + * 3、检查字典头表,如果没有就添加 + * 4、增新一条字典明细表的记录 + * @param dictData + * @return + */ + public AjaxResult dict(DictData dictData) { + //1、判断必填字段是否为空 + if(StringUtils.isEmpty(dictData.getWarehouseCode())){ + return AjaxResult.error("没有仓库编码"); + } + if(StringUtils.isEmpty(dictData.getDictLabel())){ + return AjaxResult.error("没有字典标签"); + } + if(StringUtils.isEmpty(dictData.getDictType())){ + return AjaxResult.error("没有字典类型"); + } + if(StringUtils.isEmpty(dictData.getDictValue())){ + return AjaxResult.error("没有字典键值"); + } + + //2、仓库是否正确 + int result = 0; + this.checkWarehouse(dictData.getWarehouseCode()); + + //3、检查字典头表,如果没有就添加 + DictData condition = new DictData(); + try { + condition.setDictType(dictData.getDictType()); + condition.setWarehouseCode(dictData.getWarehouseCode()); + condition.setDictValue(dictData.getDictValue()); + condition.setEnable(true); + List<DictData> dictDatas = dictDataService.selectDictDataList(dictData); + if (dictDatas.size() < 1) { + //找出字典头表的id + DictType dictType = new DictType(); + dictType.setWarehouseCode(dictData.getWarehouseCode()); + dictType.setDictType(dictData.getDictType()); + List<DictType> dictList = dictTypeService.selectDictTypeList(dictType); + if (dictList.size() < 1) { + dictType.setWarehouseId(dictData.getWarehouseId()); + dictType.setCreateBy(dictData.getCreateBy()); + dictType.setCreateTime(dictData.getCreateTime()); + if(StringUtils.isEmpty(dictType.getCreateBy())) { + result = dictTypeService.insertDictType(dictType); + }else { + result=dictTypeMapper.insertDictType(dictType); + } + dictList.add(dictType); + if (result < 1) { + throw new ServiceException("新增字典类型失败!"); + } + } + //4、增新一条字典明细表的记录 + dictData.setHeaderId(dictList.get(0).getId()); + if(StringUtils.isEmpty(dictData.getCreateBy())) { + result = dictDataService.insertDictData(dictData); + }else { + result=dictDataMapper.insertDictData(dictData); + } + if (result < 1) { + throw new ServiceException("新增字典数据失败!"); + } + } + }catch (Exception e){ + throw new ServiceException("字典数据有误!!"); + } + return AjaxResult.success("新增字典成功"); + } + + /** + * 检查是否存在物料,如果存在就修改,不存在就新增 + * 1、判断必填字段是否为空 + * 2、检查仓库和货主 + * 3、查看此物料在系统是否存在 + * @param material + * @return + */ + @Transactional + public AjaxResult material(Material material) { + + //1、判断必填字段是否为空 + if(StringUtils.isEmpty(material.getCode())){ + return AjaxResult.error("物料编码不能为空!!"); + } + if(StringUtils.isEmpty(material.getWarehouseCode())){ + return AjaxResult.error("仓库编码不能为空!!"); + } + if(StringUtils.isEmpty(material.getCompanyCode())){ + return AjaxResult.error("货主编码不能为空!!"); + } + if(StringUtils.isEmpty(material.getType())){ + return AjaxResult.error("物料类型不能为空!!"); + } + if(StringUtils.isEmpty(material.getName())){ + return AjaxResult.error("物料名称不能为空!!"); + } + if(StringUtils.isEmpty(material.getSpec())){ + return AjaxResult.error("物料规格不能为空!!"); + } + if(StringUtils.isEmpty(material.getUnit())){ + return AjaxResult.error("物料单位不能为空!!"); + } + + //2、检查仓库和货主 + this.checkWarehouse(material.getWarehouseCode()); + LambdaQueryWrapper<Company> companyLam = Wrappers.lambdaQuery(); + companyLam.eq(Company::getCode,material.getCompanyCode()); + Company company=companyService.getOne(companyLam); + if(company==null){ + return AjaxResult.error("没有该货主!!"); + } + + Boolean flag = false; + try { + //3、查看此物料在系统是否存在 + LambdaQueryWrapper<Material> materialLam = Wrappers.lambdaQuery(); + materialLam.eq(Material::getCode,material.getCode()) + .eq(Material::getWarehouseCode,material.getWarehouseCode()); + Material entity = materialService.getOne(materialLam); + if (entity == null) { + flag = materialService.save(material); + if (flag == false) { + throw new ServiceException("新增物料失败!"); + } + } else { +// return AjaxResult.error("已有该物料,无法进行修改!!"); + material.setId(entity.getId()); + flag = materialService.updateById(material); + if (flag == false) { + throw new ServiceException("更新物料失败!"); + }else { + return AjaxResult.success("更新物流成功!"); + } + } + }catch (Exception e){ + throw new ServiceException("物料数据问题"); + } + return AjaxResult.success("新增物料成功"); + } + + + + /** + * 人员档案通用接口 + * 1、判断必填字段是否为空 + * 2、判断系统中是否有该用户,如果有则更新,如果没有则新增 + *新增: (1)、默认密码为123456 + * (2)默认为普通用户 + * (3)默认为长沙仓库 + * @param user + * @return + */ + public AjaxResult user(User user){ + //1、判断必填字段是否为空 + int result = 0; + User user1 = new User(); + if(user.getLoginName()==null || user.getLoginName()=="") { + return AjaxResult.error("没有人员编码!!"); + } + if (user.getUserName()==null || user.getUserName()==""){ + return AjaxResult.error("没有人员名称!!"); + } + if(user.getDeptId()==null){ + return AjaxResult.error("没有部门ID!!"); + } + if(iDeptService.selectDeptById(user.getDeptId())==null){ + return AjaxResult.error("系统没有此部门!!"); + } + try { + user1.setLoginName(user.getLoginName()); + //2、判断系统中是否有该用户,如果有则更新,如果没有则新增 + if (iUserService.selectmen(user.getLoginName()) == null) { + //(1)默认密码为123456 + if(user.getPassword()==null) { + user.setPassword("123456"); + } + //(2)默认为普通用户 + if(StringUtils.isEmpty(user.getRoleIds())) { + List<Integer> roleIds=new ArrayList<>(); + roleIds.add(2); + user.setRoleIds(roleIds); + } + //(3)默认为长沙仓库 + if(StringUtils.isEmpty(user.getCompanyIdList())) { + List<Integer> companyIdList = new ArrayList<>(); + companyIdList.add(2); + user.setCompanyIdList(companyIdList); + } + result = iUserService.insertUser(user); + if (result < 1) { + throw new ServiceException("新增人员档案失败!"); + } else { + return AjaxResult.success("新增人员档案成功!"); + } + } else { + return AjaxResult.error("已有该人员档案,无法进行修改!"); +// result = iUserService.updateUser(user); +// if (result < 1) { +// throw new ServiceException("更新人员档案失败!"); +// } else { +// return AjaxResult.success("更新人员档案成功!"); +// } + } + }catch (Exception e){ + throw new ServiceException("数据问题。。。"); + } + } + + + + /** + * 部门档案通用接口 + * 1、判断必填字段是否为空 + * 2、部门编码长度应是双数 + * + * @param dept + * @return + */ + @Transactional + public AjaxResult dept(Dept dept) { + + //1、判断必填字段是否为空 + int result = 0; + String code = dept.getCode(); + if (code == null || code == "") { + return AjaxResult.error("部门编码不能为空!!"); + } + try { + Dept rs = iDeptService.selectDepts(code); + + //2、部门编码长度应是双数 + if (rs == null) { + int x = code.length() % 2; + if (x != 0) { + return AjaxResult.error("部门编码长度应是双数"); + } else { + int y = code.length() / 2; + if (y >= 1) { + String scode = code.substring(0, 2); + if (iDeptService.selectDepts(scode) == null) { + dept.setCode(scode); + dept.setParentId(100); + dept.setAncestors("0,100"); + dept.setOrderNum("1"); + result = iDeptService.insertDept(dept); + if (result < 1) { + throw new ServiceException("新增部门档案失败!"); + } + } + } + for (int z = 1; z <=y; z++) { + + //找到上级部门 + String sqcode = code.substring(0, 2 * (z - 1)); + Dept sdept = iDeptService.selectDepts(sqcode); + String sscode = code.substring(0, 2 * z); + if (iDeptService.selectDepts(sscode) == null) { + dept.setCode(sscode); + dept.setParentId(sdept.getId()); + dept.setAncestors(sdept.getAncestors() + "," + sdept.getId()); + dept.setOrderNum(String.valueOf(z)); + result = iDeptService.insertDept(dept); + if (result < 1) { + throw new ServiceException("新增部门档案失败!"); + } + } + } + } + return AjaxResult.success("新增部门成功"); + } else { + dept.setId(rs.getId()); + int num = iDeptService.updatesDept(dept); + if (num < 1) { + throw new ServiceException("部门修改失败"); + } else { + return AjaxResult.success("部门修改成功"); + } + } + } catch (Exception e) { + throw new ServiceException("数据问题。。。"); + } + } + + /** + * 客户档案通用接口 + * 1、判断必填字段是否为空 + * 2、检查仓库 + * 3、查看此客户在系统是否存在 + * @param customer + * @return + */ + public AjaxResult customer(Customer customer){ + Boolean flag = true; + //1、判断必填字段是否为空 + if(customer.getCode()==null||customer.getCode()=="") { + return AjaxResult.error("客户代码不能为空!!"); + } + if(StringUtils.isEmpty(customer.getWarehouseCode())){ + return AjaxResult.error("没有仓库编码"); + } + if(StringUtils.isEmpty(customer.getName())){ + return AjaxResult.error("没有客户名称"); + } + if(StringUtils.isEmpty(customer.getCompanyCode())){ + return AjaxResult.error("没有货主编码"); + } + try { + //2、检查仓库 + this.checkWarehouse(customer.getWarehouseCode()); + + //3、查看此客户在系统是否存在 + LambdaQueryWrapper<Customer> customerLam = Wrappers.lambdaQuery(); + customerLam.eq(Customer::getCode,customer.getCode()) + .eq(Customer::getWarehouseCode,customer.getWarehouseCode()); + Customer ctr = iCustomerService.getOne(customerLam); + + //不存在添加 + if ( ctr == null) { + flag = iCustomerService.save(customer); + if (flag == false) { + throw new ServiceException("新增客户档案失败!"); + } else { + return AjaxResult.success("新增客户档案成功!"); + } + } else { + return AjaxResult.error("已有该客户,无法进行修改!!"); +// customer.setId(rs.getId()); +// result = iCustomerService.updateByModel(customer); +// if (result < 1) { +// throw new ServiceException("更新客户档案失败!"); +// } else { +// return AjaxResult.success("更新客户档案成功!"); +// } + } + }catch (Exception e){ + throw new ServiceException("数据问题。。。"); + } + } + + /** + * 仓库档案通用接口 + * 1、判断必填字段是否为空 + * 2、判断系统中是否有该仓库,若有则更新,若无则新增 + * @param warehouse + * @return + */ + public AjaxResult warehouse(Warehouse warehouse){ + if(warehouse.getCode()==null||warehouse.getCode()=="") { + return AjaxResult.error("仓库编码不能为空!!"); + } + if(warehouse.getName()==null||warehouse.getName()=="") { + return AjaxResult.error("仓库名称不能为空!!"); + } + try { + LambdaQueryWrapper<Warehouse> warehouseLam = Wrappers.lambdaQuery(); + warehouseLam.eq(Warehouse::getCode,warehouse.getCode()); + Warehouse whs = iWarehouseService.getOne(warehouseLam); + + //2、判断系统中是否有该仓库,若有则更新,若无则新增 + if (whs == null) { + Boolean flag = iWarehouseService.save(warehouse); + if (flag == false) { + throw new ServiceException("新增仓库档案失败!"); + } else { + return AjaxResult.success("新增仓库档案成功!"); + } + } else { + return AjaxResult.error("已有该仓库,无法进行修改!"); +// warehouse.setId(rs.getId()); +// result = iWarehouseService.updateByModel(warehouse); +// if (result < 1) { +// throw new ServiceException("更新仓库档案失败!"); +// } else { +// return AjaxResult.success("更新仓库档案成功!"); +// } + } + }catch (Exception e){ + throw new ServiceException("仓库数据问题。。。"); + } + } + + /** + * 供应商档案通用接口 + * 1、判断必填字段是否为空 + * 2、检查仓库 + * 3、查看此供应商在系统是否存在 + * @param supplier + * @return + */ + public AjaxResult supplier(Supplier supplier){ + + //1、判断必填字段是否为空 + if(StringUtils.isEmpty(supplier.getCode())){ + return AjaxResult.error("没有供应商代码"); + } + if(StringUtils.isEmpty(supplier.getName())){ + return AjaxResult.error("没有供应商名称"); + } + if(StringUtils.isEmpty(supplier.getWarehouseCode())){ + return AjaxResult.error("没有仓库编码"); + } + + //2、检查仓库 + this.checkWarehouse(supplier.getCode()); + + //3、查看此供应商在系统是否存在 + try { + LambdaQueryWrapper<Supplier> supplierLam = Wrappers.lambdaQuery(); + supplierLam.eq(Supplier::getCode,supplier.getCode()) + .eq(Supplier::getWarehouseCode,supplier.getWarehouseCode()); + Supplier spl=iSupplierService.getOne(supplierLam); + + if (spl== null) { + Boolean flag = iSupplierService.save(supplier); + if (flag == false) { + throw new ServiceException("新增供应商失败!"); + } else { + return AjaxResult.success("新增供应商成功!"); + } + } else { + return AjaxResult.error("已有该供应商,无法修改!!"); + } + }catch (Exception e){ + throw new ServiceException("供应商数据问题。。。"); + } + } +} diff --git a/src/main/java/com/huaheng/pc/system/user/controller/IndexController.java b/src/main/java/com/huaheng/pc/system/user/controller/IndexController.java index 75ba1e2..c7010c9 100644 --- a/src/main/java/com/huaheng/pc/system/user/controller/IndexController.java +++ b/src/main/java/com/huaheng/pc/system/user/controller/IndexController.java @@ -73,7 +73,7 @@ public class IndexController extends BaseController pie.itemStyle().emphasis().setShadowBlur(10); pie.itemStyle().emphasis().setShadowOffsetX(0); pie.itemStyle().emphasis().setShadowColor("rgba(0, 0, 0, 0.4)"); - String sql = "SELECT d.dictLabel '状态', i.qty '库存' FROM (SELECT status ,SUM(qty) qty FROM inventoryHeader WHERE warehouseCode = " + ShiroUtils.getWarehouseCode() + " GROUP BY status) i INNER JOIN sys_dict_data d ON i.status= d.dictValue AND d.warehouseCode = ' " + ShiroUtils.getWarehouseCode()+"' ;"; + String sql = "SELECT d.dictLabel '状态', i.qty '库存' FROM (SELECT inventorySts ,SUM(qty) qty FROM inventory_detail WHERE warehouseCode = '" + ShiroUtils.getWarehouseCode()+"' GROUP BY inventorySts) i INNER JOIN sys_dict_data d ON i.inventorySts= d.dictValue AND d.warehouseCode = '" + ShiroUtils.getWarehouseCode()+"' ;"; List<LinkedHashMap<String, Object>> results = mapper.selectCommon(sql); for(LinkedHashMap<String, Object> item : results){ ChartData chartData = new ChartData(); @@ -147,7 +147,7 @@ public class IndexController extends BaseController " union all\n" + " SELECT date_sub(curdate(), interval 6 day) as click_date\n" + ") a left join (\n" + - "SELECT DATE(h.created) AS created , SUM(d.qty) AS taskQty from shipment_container_detail d join shipment_container_header h on d.shippingContainerId = h.id and h.warehouseCode='"+ShiroUtils.getWarehouseCode()+"' WHERE h.created >= DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND h.enable>19 GROUP BY DATE(h.created)\n" + + "SELECT DATE(h.created) AS created , SUM(d.qty) AS taskQty from shipment_container_detail d join shipment_container_header h on d.shippingContainerId = h.id and h.warehouseCode='"+ShiroUtils.getWarehouseCode()+"' WHERE h.created >= DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND h.status=30 GROUP BY DATE(h.created)\n" + ") b on a.click_date = b.created ORDER BY a.click_date;"; List<LinkedHashMap<String, Object>> list = mapper.selectCommon(sql); @@ -167,7 +167,7 @@ public class IndexController extends BaseController " union all\n" + " SELECT date_sub(curdate(), interval 6 day) as click_date\n" + ") a left join (\n" + - "SELECT DATE(h.created) AS created , SUM(d.qty) AS taskQty from receipt_container_detail d join receipt_container_header h on d.headerId = h.id and h.warehouseCode="+ShiroUtils.getWarehouseCode()+" WHERE h.created >= DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND h.processStamp=20 GROUP BY DATE(h.created)\n" + + "SELECT DATE(h.created) AS created , SUM(d.qty) AS taskQty from receipt_container_detail d join receipt_container_header h on d.receiptContainerId = h.id and h.warehouseCode='"+ShiroUtils.getWarehouseCode()+"' WHERE h.created >= DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND h.processStamp=20 GROUP BY DATE(h.created)\n" + ") b on a.click_date = b.created ORDER BY a.click_date;"; List<LinkedHashMap<String, Object>> list2 = mapper.selectCommon(sql); @@ -211,7 +211,7 @@ public class IndexController extends BaseController @GetMapping("index/getInventoryProp") @ResponseBody public String getInventoryProp(){ - String sql = "SELECT m.`name`,sum(i.qty) as total from inventoryHeader i join material m on i.materialCode = m.`code` and i.warehouseId = m.warehouseId AND i.warehouseCode = "+ShiroUtils.getWarehouseCode()+" \n" + + String sql = "SELECT m.`name`,sum(i.qty) as total from inventory_detail i join material m on i.materialCode = m.`code` and i.warehouseCode = m.warehouseCode AND i.warehouseCode = '"+ShiroUtils.getWarehouseCode()+"' \n" + "GROUP BY m.`name` ORDER BY total desc;"; List<LinkedHashMap<String, Object>> results = mapper.selectCommon(sql); diff --git a/src/main/resources/templates/main.html b/src/main/resources/templates/main.html index d29a611..df52bff 100644 --- a/src/main/resources/templates/main.html +++ b/src/main/resources/templates/main.html @@ -112,18 +112,18 @@ var chart4 = echarts.init(document.getElementById('chart4')); function refresh() { - // $.get("../index/getShipmentsLast7Days").done(function (data) { - // chart1.setOption(JSON.parse(data)); - // }) + $.get("../index/getShipmentsLast7Days").done(function (data) { + chart1.setOption(JSON.parse(data)); + }) $.get("../index/getLocationProp").done(function (data) { chart2.setOption(JSON.parse(data)); }); - // $.get("../index/getInventoryStatus").done(function (data) { - // chart3.setOption(JSON.parse(data)); - // }) - // $.get("../index/getInventoryProp").done(function(data){ - // chart4.setOption(JSON.parse(data)); - // }); + $.get("../index/getInventoryStatus").done(function (data) { + chart3.setOption(JSON.parse(data)); + }) + $.get("../index/getInventoryProp").done(function(data){ + chart4.setOption(JSON.parse(data)); + }); $.get("../index/getCommonData").done(function (data) { if(data.code==200){