Commit 435ed22fb38b3109af45aad13d6d1ebc536a2fa8

Authored by xqs
2 parents 6ebc5322 3d04d270

Merge branch 'develop' of http://172.16.29.40:8010/wms/wms2 into develop

src/main/java/com/huaheng/api/general/controller/BasicDataApi.java 0 → 100644
  1 +package com.huaheng.api.general.controller;
  2 +
  3 +import com.huaheng.api.general.service.BasicDataApiService;
  4 +import com.huaheng.framework.aspectj.lang.annotation.Log;
  5 +import com.huaheng.framework.aspectj.lang.constant.BusinessType;
  6 +import com.huaheng.framework.web.controller.BaseController;
  7 +import com.huaheng.framework.web.domain.AjaxResult;
  8 +import com.huaheng.pc.config.customer.domain.Customer;
  9 +import com.huaheng.pc.config.material.domain.Material;
  10 +import com.huaheng.pc.config.supplier.domain.Supplier;
  11 +import com.huaheng.pc.config.warehouse.domain.Warehouse;
  12 +import com.huaheng.pc.system.dept.domain.Dept;
  13 +import com.huaheng.pc.system.dict.domain.DictData;
  14 +import com.huaheng.pc.system.user.domain.User;
  15 +import io.swagger.annotations.Api;
  16 +import io.swagger.annotations.ApiOperation;
  17 +import org.springframework.beans.factory.annotation.Autowired;
  18 +import org.springframework.web.bind.annotation.*;
  19 +
  20 +@RestController
  21 +@RequestMapping("/api/basicData")
  22 +@Api(tags = {"basicData"}, description = "基础数据接口")
  23 +public class BasicDataApi extends BaseController {
  24 +
  25 + @Autowired
  26 + private BasicDataApiService basicDataApiService;
  27 +
  28 + /**
  29 + * 同步物料
  30 + */
  31 + @Log(title = "物料添加", action = BusinessType.INSERT)
  32 + @PostMapping("/material")
  33 + @ApiOperation("物料添加公共接口")
  34 + @ResponseBody
  35 + public AjaxResult MaterialApi(@RequestBody Material material)
  36 + {
  37 + AjaxResult ajaxResult = basicDataApiService.material(material);
  38 + return ajaxResult;
  39 + }
  40 +
  41 + /**
  42 + * 同步字典
  43 + */
  44 + @Log(title = "字典添加", action = BusinessType.INSERT)
  45 + @PostMapping("/dictData")
  46 + @ApiOperation("字典添加公共接口")
  47 + @ResponseBody
  48 + public AjaxResult UnitlApi(@RequestBody DictData dictData)
  49 + {
  50 + AjaxResult ajaxResult = basicDataApiService.dict(dictData);
  51 + return ajaxResult;
  52 + }
  53 +
  54 +
  55 +
  56 + /**
  57 + * 同步仓库和货主
  58 + */
  59 + @Log(title = "仓库添加", action = BusinessType.INSERT)
  60 + @PostMapping("/warehouse")
  61 + @ApiOperation("仓库添加公共接口")
  62 + @ResponseBody
  63 + public AjaxResult WarehouseApi(@RequestBody Warehouse warehouse)
  64 + {
  65 + AjaxResult ajaxResult = basicDataApiService.warehouse(warehouse);
  66 + return ajaxResult;
  67 + }
  68 +
  69 + /**
  70 + * 同步客户档案
  71 + */
  72 + @Log(title = "客户档案添加", action = BusinessType.INSERT)
  73 + @PostMapping("/customer")
  74 + @ApiOperation("客户档案添加公共接口")
  75 + @ResponseBody
  76 + public AjaxResult CustomerApi(@RequestBody Customer customer)
  77 + {
  78 + AjaxResult ajaxResult = basicDataApiService.customer(customer);
  79 + return ajaxResult;
  80 + }
  81 +
  82 + /**
  83 + * 同步部门档案
  84 + */
  85 + @Log(title = "部门档案添加", action = BusinessType.INSERT)
  86 + @PostMapping("/dept")
  87 + @ApiOperation("部门档案添加公共接口")
  88 + @ResponseBody
  89 + public AjaxResult DeptApi(@RequestBody Dept dept)
  90 + {
  91 + AjaxResult ajaxResult = basicDataApiService.dept(dept);
  92 + return ajaxResult;
  93 + }
  94 +
  95 + /**
  96 + * 同步人员档案
  97 + */
  98 + @Log(title = "人员档案添加", action = BusinessType.INSERT)
  99 + @PostMapping("/user")
  100 + @ApiOperation("人员档案添加公共接口")
  101 + @ResponseBody
  102 + public AjaxResult UserApi(@RequestBody User user)
  103 + {
  104 + AjaxResult ajaxResult = basicDataApiService.user(user);
  105 + return ajaxResult;
  106 + }
  107 +
  108 + /**
  109 + * 同步供应商档案
  110 + */
  111 + @Log(title = "供应商档案添加", action = BusinessType.INSERT)
  112 + @PostMapping("/supplier")
  113 + @ApiOperation("供应商档案添加公共接口")
  114 + @ResponseBody
  115 + public AjaxResult SupplierApi(@RequestBody Supplier supplier){
  116 + AjaxResult ajaxResult = basicDataApiService.supplier(supplier);
  117 + return ajaxResult;
  118 + }
  119 +
  120 +
  121 +
  122 +
  123 +}
... ...
src/main/java/com/huaheng/api/general/controller/LoginApi.java 0 → 100644
  1 +package com.huaheng.api.general.controller;
  2 +
  3 +import com.alibaba.fastjson.JSONException;
  4 +import com.huaheng.common.utils.DataUtils;
  5 +import com.huaheng.framework.web.controller.BaseController;
  6 +import com.huaheng.framework.web.domain.AjaxResult;
  7 +import com.huaheng.pc.system.user.service.IUserService;
  8 +import io.swagger.annotations.Api;
  9 +import io.swagger.annotations.ApiOperation;
  10 +import io.swagger.annotations.ApiParam;
  11 +import org.springframework.beans.factory.annotation.Autowired;
  12 +import org.springframework.web.bind.annotation.PostMapping;
  13 +import org.springframework.web.bind.annotation.RequestBody;
  14 +import org.springframework.web.bind.annotation.RequestMapping;
  15 +import org.springframework.web.bind.annotation.RestController;
  16 +
  17 +import java.util.Map;
  18 +
  19 +
  20 +@RestController
  21 +@RequestMapping("/api")
  22 +@Api(tags = {"Login"}, description = "登陆接口")
  23 +public class LoginApi extends BaseController {
  24 +
  25 + @Autowired
  26 + private IUserService userService;
  27 +
  28 + @PostMapping("/login")
  29 + @ApiOperation("登陆接口")
  30 + public AjaxResult login(@RequestBody @ApiParam(value="登陆的Map集合") Map<String, String> param)
  31 + {
  32 + if (param.get("username") == null)
  33 + throw new JSONException("username(用户名)不能为空");
  34 + if (param.get("password") == null)
  35 + throw new JSONException("password(密码)不能为空");
  36 + if (param.get("warehouseCode") == null)
  37 + throw new JSONException("warehouseCode(仓库编码)不能为空");
  38 + String username = param.get("username");
  39 + String password = param.get("password");
  40 + String warehouseCode = param.get("warehouseCode");
  41 + AjaxResult ajaxResult = userService.login(username, password, warehouseCode, false);
  42 + return ajaxResult;
  43 + }
  44 +
  45 +
  46 + @PostMapping("/heartbeat")
  47 + @ApiOperation("心跳接口,用于延长cookie有效期")
  48 + public AjaxResult heartbeat()
  49 + {
  50 + return AjaxResult.success("success");
  51 + }
  52 +
  53 +
  54 +}
... ...
src/main/java/com/huaheng/api/general/service/BasicDataApiService.java 0 → 100644
  1 +package com.huaheng.api.general.service;
  2 +
  3 +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  4 +import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  5 +import com.huaheng.common.exception.service.ServiceException;
  6 +import com.huaheng.common.utils.StringUtils;
  7 +import com.huaheng.framework.web.domain.AjaxResult;
  8 +import com.huaheng.pc.config.company.domain.Company;
  9 +import com.huaheng.pc.config.company.service.CompanyService;
  10 +import com.huaheng.pc.config.customer.domain.Customer;
  11 +import com.huaheng.pc.config.customer.service.CustomerServiceImpl;
  12 +import com.huaheng.pc.config.material.domain.Material;
  13 +import com.huaheng.pc.config.material.service.MaterialService;
  14 +import com.huaheng.pc.config.supplier.domain.Supplier;
  15 +import com.huaheng.pc.config.supplier.service.SupplierService;
  16 +import com.huaheng.pc.config.warehouse.domain.Warehouse;
  17 +import com.huaheng.pc.config.warehouse.service.WarehouseService;
  18 +import com.huaheng.pc.system.dept.domain.Dept;
  19 +import com.huaheng.pc.system.dept.service.IDeptService;
  20 +import com.huaheng.pc.system.dict.domain.DictData;
  21 +import com.huaheng.pc.system.dict.domain.DictType;
  22 +import com.huaheng.pc.system.dict.mapper.DictDataMapper;
  23 +import com.huaheng.pc.system.dict.mapper.DictTypeMapper;
  24 +import com.huaheng.pc.system.dict.service.IDictDataService;
  25 +import com.huaheng.pc.system.dict.service.IDictTypeService;
  26 +import com.huaheng.pc.system.user.domain.User;
  27 +import com.huaheng.pc.system.user.service.IUserService;
  28 +import org.springframework.beans.factory.annotation.Autowired;
  29 +import org.springframework.stereotype.Component;
  30 +import org.springframework.transaction.annotation.Transactional;
  31 +
  32 +import javax.annotation.Resource;
  33 +import java.util.ArrayList;
  34 +import java.util.List;
  35 +
  36 +@Component
  37 +@Transactional
  38 +public class BasicDataApiService {
  39 + @Autowired
  40 + IDictTypeService dictTypeService;
  41 + @Autowired
  42 + IDictDataService dictDataService;
  43 + @Autowired
  44 + MaterialService materialService;
  45 +
  46 + @Resource
  47 + private DictTypeMapper dictTypeMapper;
  48 + @Resource
  49 + private DictDataMapper dictDataMapper;
  50 +
  51 + @Autowired
  52 + IUserService iUserService;
  53 +
  54 + @Autowired
  55 + IDeptService iDeptService;
  56 +
  57 + @Autowired
  58 + CustomerServiceImpl iCustomerService;
  59 +
  60 + @Autowired
  61 + WarehouseService iWarehouseService;
  62 +
  63 + @Autowired
  64 + SupplierService iSupplierService;
  65 +
  66 + @Autowired
  67 + CompanyService companyService;
  68 +
  69 + //检查仓库
  70 + public Warehouse checkWarehouse(String code) {
  71 + LambdaQueryWrapper<Warehouse> warehouseLam = Wrappers.lambdaQuery();
  72 + warehouseLam.eq(Warehouse::getCode, code);
  73 + Warehouse warehouse = iWarehouseService.getOne(warehouseLam);
  74 + if (warehouse == null) {
  75 + throw new ServiceException("数据出现问题,系统没有该仓库");
  76 + }
  77 + return warehouse;
  78 + }
  79 +
  80 + /**
  81 + * 字典通用接口
  82 + * 1、判断必填字段是否为空
  83 + * 2、仓库是否正确
  84 + * 3、检查字典头表,如果没有就添加
  85 + * 4、增新一条字典明细表的记录
  86 + * @param dictData
  87 + * @return
  88 + */
  89 + public AjaxResult dict(DictData dictData) {
  90 + //1、判断必填字段是否为空
  91 + if(StringUtils.isEmpty(dictData.getWarehouseCode())){
  92 + return AjaxResult.error("没有仓库编码");
  93 + }
  94 + if(StringUtils.isEmpty(dictData.getDictLabel())){
  95 + return AjaxResult.error("没有字典标签");
  96 + }
  97 + if(StringUtils.isEmpty(dictData.getDictType())){
  98 + return AjaxResult.error("没有字典类型");
  99 + }
  100 + if(StringUtils.isEmpty(dictData.getDictValue())){
  101 + return AjaxResult.error("没有字典键值");
  102 + }
  103 +
  104 + //2、仓库是否正确
  105 + int result = 0;
  106 + this.checkWarehouse(dictData.getWarehouseCode());
  107 +
  108 + //3、检查字典头表,如果没有就添加
  109 + DictData condition = new DictData();
  110 + try {
  111 + condition.setDictType(dictData.getDictType());
  112 + condition.setWarehouseCode(dictData.getWarehouseCode());
  113 + condition.setDictValue(dictData.getDictValue());
  114 + condition.setEnable(true);
  115 + List<DictData> dictDatas = dictDataService.selectDictDataList(dictData);
  116 + if (dictDatas.size() < 1) {
  117 + //找出字典头表的id
  118 + DictType dictType = new DictType();
  119 + dictType.setWarehouseCode(dictData.getWarehouseCode());
  120 + dictType.setDictType(dictData.getDictType());
  121 + List<DictType> dictList = dictTypeService.selectDictTypeList(dictType);
  122 + if (dictList.size() < 1) {
  123 + dictType.setWarehouseId(dictData.getWarehouseId());
  124 + dictType.setCreateBy(dictData.getCreateBy());
  125 + dictType.setCreateTime(dictData.getCreateTime());
  126 + if(StringUtils.isEmpty(dictType.getCreateBy())) {
  127 + result = dictTypeService.insertDictType(dictType);
  128 + }else {
  129 + result=dictTypeMapper.insertDictType(dictType);
  130 + }
  131 + dictList.add(dictType);
  132 + if (result < 1) {
  133 + throw new ServiceException("新增字典类型失败!");
  134 + }
  135 + }
  136 + //4、增新一条字典明细表的记录
  137 + dictData.setHeaderId(dictList.get(0).getId());
  138 + if(StringUtils.isEmpty(dictData.getCreateBy())) {
  139 + result = dictDataService.insertDictData(dictData);
  140 + }else {
  141 + result=dictDataMapper.insertDictData(dictData);
  142 + }
  143 + if (result < 1) {
  144 + throw new ServiceException("新增字典数据失败!");
  145 + }
  146 + }
  147 + }catch (Exception e){
  148 + throw new ServiceException("字典数据有误!!");
  149 + }
  150 + return AjaxResult.success("新增字典成功");
  151 + }
  152 +
  153 + /**
  154 + * 检查是否存在物料,如果存在就修改,不存在就新增
  155 + * 1、判断必填字段是否为空
  156 + * 2、检查仓库和货主
  157 + * 3、查看此物料在系统是否存在
  158 + * @param material
  159 + * @return
  160 + */
  161 + @Transactional
  162 + public AjaxResult material(Material material) {
  163 +
  164 + //1、判断必填字段是否为空
  165 + if(StringUtils.isEmpty(material.getCode())){
  166 + return AjaxResult.error("物料编码不能为空!!");
  167 + }
  168 + if(StringUtils.isEmpty(material.getWarehouseCode())){
  169 + return AjaxResult.error("仓库编码不能为空!!");
  170 + }
  171 + if(StringUtils.isEmpty(material.getCompanyCode())){
  172 + return AjaxResult.error("货主编码不能为空!!");
  173 + }
  174 + if(StringUtils.isEmpty(material.getType())){
  175 + return AjaxResult.error("物料类型不能为空!!");
  176 + }
  177 + if(StringUtils.isEmpty(material.getName())){
  178 + return AjaxResult.error("物料名称不能为空!!");
  179 + }
  180 + if(StringUtils.isEmpty(material.getSpec())){
  181 + return AjaxResult.error("物料规格不能为空!!");
  182 + }
  183 + if(StringUtils.isEmpty(material.getUnit())){
  184 + return AjaxResult.error("物料单位不能为空!!");
  185 + }
  186 +
  187 + //2、检查仓库和货主
  188 + this.checkWarehouse(material.getWarehouseCode());
  189 + LambdaQueryWrapper<Company> companyLam = Wrappers.lambdaQuery();
  190 + companyLam.eq(Company::getCode,material.getCompanyCode());
  191 + Company company=companyService.getOne(companyLam);
  192 + if(company==null){
  193 + return AjaxResult.error("没有该货主!!");
  194 + }
  195 +
  196 + Boolean flag = false;
  197 + try {
  198 + //3、查看此物料在系统是否存在
  199 + LambdaQueryWrapper<Material> materialLam = Wrappers.lambdaQuery();
  200 + materialLam.eq(Material::getCode,material.getCode())
  201 + .eq(Material::getWarehouseCode,material.getWarehouseCode());
  202 + Material entity = materialService.getOne(materialLam);
  203 + if (entity == null) {
  204 + flag = materialService.save(material);
  205 + if (flag == false) {
  206 + throw new ServiceException("新增物料失败!");
  207 + }
  208 + } else {
  209 +// return AjaxResult.error("已有该物料,无法进行修改!!");
  210 + material.setId(entity.getId());
  211 + flag = materialService.updateById(material);
  212 + if (flag == false) {
  213 + throw new ServiceException("更新物料失败!");
  214 + }else {
  215 + return AjaxResult.success("更新物流成功!");
  216 + }
  217 + }
  218 + }catch (Exception e){
  219 + throw new ServiceException("物料数据问题");
  220 + }
  221 + return AjaxResult.success("新增物料成功");
  222 + }
  223 +
  224 +
  225 +
  226 + /**
  227 + * 人员档案通用接口
  228 + * 1、判断必填字段是否为空
  229 + * 2、判断系统中是否有该用户,如果有则更新,如果没有则新增
  230 + *新增: (1)、默认密码为123456
  231 + * (2)默认为普通用户
  232 + * (3)默认为长沙仓库
  233 + * @param user
  234 + * @return
  235 + */
  236 + public AjaxResult user(User user){
  237 + //1、判断必填字段是否为空
  238 + int result = 0;
  239 + User user1 = new User();
  240 + if(user.getLoginName()==null || user.getLoginName()=="") {
  241 + return AjaxResult.error("没有人员编码!!");
  242 + }
  243 + if (user.getUserName()==null || user.getUserName()==""){
  244 + return AjaxResult.error("没有人员名称!!");
  245 + }
  246 + if(user.getDeptId()==null){
  247 + return AjaxResult.error("没有部门ID!!");
  248 + }
  249 + if(iDeptService.selectDeptById(user.getDeptId())==null){
  250 + return AjaxResult.error("系统没有此部门!!");
  251 + }
  252 + try {
  253 + user1.setLoginName(user.getLoginName());
  254 + //2、判断系统中是否有该用户,如果有则更新,如果没有则新增
  255 + if (iUserService.selectmen(user.getLoginName()) == null) {
  256 + //(1)默认密码为123456
  257 + if(user.getPassword()==null) {
  258 + user.setPassword("123456");
  259 + }
  260 + //(2)默认为普通用户
  261 + if(StringUtils.isEmpty(user.getRoleIds())) {
  262 + List<Integer> roleIds=new ArrayList<>();
  263 + roleIds.add(2);
  264 + user.setRoleIds(roleIds);
  265 + }
  266 + //(3)默认为长沙仓库
  267 + if(StringUtils.isEmpty(user.getCompanyIdList())) {
  268 + List<Integer> companyIdList = new ArrayList<>();
  269 + companyIdList.add(2);
  270 + user.setCompanyIdList(companyIdList);
  271 + }
  272 + result = iUserService.insertUser(user);
  273 + if (result < 1) {
  274 + throw new ServiceException("新增人员档案失败!");
  275 + } else {
  276 + return AjaxResult.success("新增人员档案成功!");
  277 + }
  278 + } else {
  279 + return AjaxResult.error("已有该人员档案,无法进行修改!");
  280 +// result = iUserService.updateUser(user);
  281 +// if (result < 1) {
  282 +// throw new ServiceException("更新人员档案失败!");
  283 +// } else {
  284 +// return AjaxResult.success("更新人员档案成功!");
  285 +// }
  286 + }
  287 + }catch (Exception e){
  288 + throw new ServiceException("数据问题。。。");
  289 + }
  290 + }
  291 +
  292 +
  293 +
  294 + /**
  295 + * 部门档案通用接口
  296 + * 1、判断必填字段是否为空
  297 + * 2、部门编码长度应是双数
  298 + *
  299 + * @param dept
  300 + * @return
  301 + */
  302 + @Transactional
  303 + public AjaxResult dept(Dept dept) {
  304 +
  305 + //1、判断必填字段是否为空
  306 + int result = 0;
  307 + String code = dept.getCode();
  308 + if (code == null || code == "") {
  309 + return AjaxResult.error("部门编码不能为空!!");
  310 + }
  311 + try {
  312 + Dept rs = iDeptService.selectDepts(code);
  313 +
  314 + //2、部门编码长度应是双数
  315 + if (rs == null) {
  316 + int x = code.length() % 2;
  317 + if (x != 0) {
  318 + return AjaxResult.error("部门编码长度应是双数");
  319 + } else {
  320 + int y = code.length() / 2;
  321 + if (y >= 1) {
  322 + String scode = code.substring(0, 2);
  323 + if (iDeptService.selectDepts(scode) == null) {
  324 + dept.setCode(scode);
  325 + dept.setParentId(100);
  326 + dept.setAncestors("0,100");
  327 + dept.setOrderNum("1");
  328 + result = iDeptService.insertDept(dept);
  329 + if (result < 1) {
  330 + throw new ServiceException("新增部门档案失败!");
  331 + }
  332 + }
  333 + }
  334 + for (int z = 1; z <=y; z++) {
  335 +
  336 + //找到上级部门
  337 + String sqcode = code.substring(0, 2 * (z - 1));
  338 + Dept sdept = iDeptService.selectDepts(sqcode);
  339 + String sscode = code.substring(0, 2 * z);
  340 + if (iDeptService.selectDepts(sscode) == null) {
  341 + dept.setCode(sscode);
  342 + dept.setParentId(sdept.getId());
  343 + dept.setAncestors(sdept.getAncestors() + "," + sdept.getId());
  344 + dept.setOrderNum(String.valueOf(z));
  345 + result = iDeptService.insertDept(dept);
  346 + if (result < 1) {
  347 + throw new ServiceException("新增部门档案失败!");
  348 + }
  349 + }
  350 + }
  351 + }
  352 + return AjaxResult.success("新增部门成功");
  353 + } else {
  354 + dept.setId(rs.getId());
  355 + int num = iDeptService.updatesDept(dept);
  356 + if (num < 1) {
  357 + throw new ServiceException("部门修改失败");
  358 + } else {
  359 + return AjaxResult.success("部门修改成功");
  360 + }
  361 + }
  362 + } catch (Exception e) {
  363 + throw new ServiceException("数据问题。。。");
  364 + }
  365 + }
  366 +
  367 + /**
  368 + * 客户档案通用接口
  369 + * 1、判断必填字段是否为空
  370 + * 2、检查仓库
  371 + * 3、查看此客户在系统是否存在
  372 + * @param customer
  373 + * @return
  374 + */
  375 + public AjaxResult customer(Customer customer){
  376 + Boolean flag = true;
  377 + //1、判断必填字段是否为空
  378 + if(customer.getCode()==null||customer.getCode()=="") {
  379 + return AjaxResult.error("客户代码不能为空!!");
  380 + }
  381 + if(StringUtils.isEmpty(customer.getWarehouseCode())){
  382 + return AjaxResult.error("没有仓库编码");
  383 + }
  384 + if(StringUtils.isEmpty(customer.getName())){
  385 + return AjaxResult.error("没有客户名称");
  386 + }
  387 + if(StringUtils.isEmpty(customer.getCompanyCode())){
  388 + return AjaxResult.error("没有货主编码");
  389 + }
  390 + try {
  391 + //2、检查仓库
  392 + this.checkWarehouse(customer.getWarehouseCode());
  393 +
  394 + //3、查看此客户在系统是否存在
  395 + LambdaQueryWrapper<Customer> customerLam = Wrappers.lambdaQuery();
  396 + customerLam.eq(Customer::getCode,customer.getCode())
  397 + .eq(Customer::getWarehouseCode,customer.getWarehouseCode());
  398 + Customer ctr = iCustomerService.getOne(customerLam);
  399 +
  400 + //不存在添加
  401 + if ( ctr == null) {
  402 + flag = iCustomerService.save(customer);
  403 + if (flag == false) {
  404 + throw new ServiceException("新增客户档案失败!");
  405 + } else {
  406 + return AjaxResult.success("新增客户档案成功!");
  407 + }
  408 + } else {
  409 + return AjaxResult.error("已有该客户,无法进行修改!!");
  410 +// customer.setId(rs.getId());
  411 +// result = iCustomerService.updateByModel(customer);
  412 +// if (result < 1) {
  413 +// throw new ServiceException("更新客户档案失败!");
  414 +// } else {
  415 +// return AjaxResult.success("更新客户档案成功!");
  416 +// }
  417 + }
  418 + }catch (Exception e){
  419 + throw new ServiceException("数据问题。。。");
  420 + }
  421 + }
  422 +
  423 + /**
  424 + * 仓库档案通用接口
  425 + * 1、判断必填字段是否为空
  426 + * 2、判断系统中是否有该仓库,若有则更新,若无则新增
  427 + * @param warehouse
  428 + * @return
  429 + */
  430 + public AjaxResult warehouse(Warehouse warehouse){
  431 + if(warehouse.getCode()==null||warehouse.getCode()=="") {
  432 + return AjaxResult.error("仓库编码不能为空!!");
  433 + }
  434 + if(warehouse.getName()==null||warehouse.getName()=="") {
  435 + return AjaxResult.error("仓库名称不能为空!!");
  436 + }
  437 + try {
  438 + LambdaQueryWrapper<Warehouse> warehouseLam = Wrappers.lambdaQuery();
  439 + warehouseLam.eq(Warehouse::getCode,warehouse.getCode());
  440 + Warehouse whs = iWarehouseService.getOne(warehouseLam);
  441 +
  442 + //2、判断系统中是否有该仓库,若有则更新,若无则新增
  443 + if (whs == null) {
  444 + Boolean flag = iWarehouseService.save(warehouse);
  445 + if (flag == false) {
  446 + throw new ServiceException("新增仓库档案失败!");
  447 + } else {
  448 + return AjaxResult.success("新增仓库档案成功!");
  449 + }
  450 + } else {
  451 + return AjaxResult.error("已有该仓库,无法进行修改!");
  452 +// warehouse.setId(rs.getId());
  453 +// result = iWarehouseService.updateByModel(warehouse);
  454 +// if (result < 1) {
  455 +// throw new ServiceException("更新仓库档案失败!");
  456 +// } else {
  457 +// return AjaxResult.success("更新仓库档案成功!");
  458 +// }
  459 + }
  460 + }catch (Exception e){
  461 + throw new ServiceException("仓库数据问题。。。");
  462 + }
  463 + }
  464 +
  465 + /**
  466 + * 供应商档案通用接口
  467 + * 1、判断必填字段是否为空
  468 + * 2、检查仓库
  469 + * 3、查看此供应商在系统是否存在
  470 + * @param supplier
  471 + * @return
  472 + */
  473 + public AjaxResult supplier(Supplier supplier){
  474 +
  475 + //1、判断必填字段是否为空
  476 + if(StringUtils.isEmpty(supplier.getCode())){
  477 + return AjaxResult.error("没有供应商代码");
  478 + }
  479 + if(StringUtils.isEmpty(supplier.getName())){
  480 + return AjaxResult.error("没有供应商名称");
  481 + }
  482 + if(StringUtils.isEmpty(supplier.getWarehouseCode())){
  483 + return AjaxResult.error("没有仓库编码");
  484 + }
  485 +
  486 + //2、检查仓库
  487 + this.checkWarehouse(supplier.getCode());
  488 +
  489 + //3、查看此供应商在系统是否存在
  490 + try {
  491 + LambdaQueryWrapper<Supplier> supplierLam = Wrappers.lambdaQuery();
  492 + supplierLam.eq(Supplier::getCode,supplier.getCode())
  493 + .eq(Supplier::getWarehouseCode,supplier.getWarehouseCode());
  494 + Supplier spl=iSupplierService.getOne(supplierLam);
  495 +
  496 + if (spl== null) {
  497 + Boolean flag = iSupplierService.save(supplier);
  498 + if (flag == false) {
  499 + throw new ServiceException("新增供应商失败!");
  500 + } else {
  501 + return AjaxResult.success("新增供应商成功!");
  502 + }
  503 + } else {
  504 + return AjaxResult.error("已有该供应商,无法修改!!");
  505 + }
  506 + }catch (Exception e){
  507 + throw new ServiceException("供应商数据问题。。。");
  508 + }
  509 + }
  510 +}
... ...
src/main/java/com/huaheng/pc/system/user/controller/IndexController.java
... ... @@ -73,7 +73,7 @@ public class IndexController extends BaseController
73 73 pie.itemStyle().emphasis().setShadowBlur(10);
74 74 pie.itemStyle().emphasis().setShadowOffsetX(0);
75 75 pie.itemStyle().emphasis().setShadowColor("rgba(0, 0, 0, 0.4)");
76   - 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()+"' ;";
  76 + 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()+"' ;";
77 77 List<LinkedHashMap<String, Object>> results = mapper.selectCommon(sql);
78 78 for(LinkedHashMap<String, Object> item : results){
79 79 ChartData chartData = new ChartData();
... ... @@ -147,7 +147,7 @@ public class IndexController extends BaseController
147 147 " union all\n" +
148 148 " SELECT date_sub(curdate(), interval 6 day) as click_date\n" +
149 149 ") a left join (\n" +
150   - "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" +
  150 + "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" +
151 151 ") b on a.click_date = b.created ORDER BY a.click_date;";
152 152 List<LinkedHashMap<String, Object>> list = mapper.selectCommon(sql);
153 153  
... ... @@ -167,7 +167,7 @@ public class IndexController extends BaseController
167 167 " union all\n" +
168 168 " SELECT date_sub(curdate(), interval 6 day) as click_date\n" +
169 169 ") a left join (\n" +
170   - "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" +
  170 + "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" +
171 171 ") b on a.click_date = b.created ORDER BY a.click_date;";
172 172 List<LinkedHashMap<String, Object>> list2 = mapper.selectCommon(sql);
173 173  
... ... @@ -211,7 +211,7 @@ public class IndexController extends BaseController
211 211 @GetMapping("index/getInventoryProp")
212 212 @ResponseBody
213 213 public String getInventoryProp(){
214   - 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" +
  214 + 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" +
215 215 "GROUP BY m.`name` ORDER BY total desc;";
216 216 List<LinkedHashMap<String, Object>> results = mapper.selectCommon(sql);
217 217  
... ...
src/main/resources/templates/main.html
... ... @@ -112,18 +112,18 @@
112 112 var chart4 = echarts.init(document.getElementById('chart4'));
113 113  
114 114 function refresh() {
115   - // $.get("../index/getShipmentsLast7Days").done(function (data) {
116   - // chart1.setOption(JSON.parse(data));
117   - // })
  115 + $.get("../index/getShipmentsLast7Days").done(function (data) {
  116 + chart1.setOption(JSON.parse(data));
  117 + })
118 118 $.get("../index/getLocationProp").done(function (data) {
119 119 chart2.setOption(JSON.parse(data));
120 120 });
121   - // $.get("../index/getInventoryStatus").done(function (data) {
122   - // chart3.setOption(JSON.parse(data));
123   - // })
124   - // $.get("../index/getInventoryProp").done(function(data){
125   - // chart4.setOption(JSON.parse(data));
126   - // });
  121 + $.get("../index/getInventoryStatus").done(function (data) {
  122 + chart3.setOption(JSON.parse(data));
  123 + })
  124 + $.get("../index/getInventoryProp").done(function(data){
  125 + chart4.setOption(JSON.parse(data));
  126 + });
127 127  
128 128 $.get("../index/getCommonData").done(function (data) {
129 129 if(data.code==200){
... ...