GeneralService.java 3.57 KB
package com.huaheng.api.U8.service;

import com.huaheng.api.Common.GeneralApi;
import com.huaheng.api.U8.domain.ICSInventoryModel;
import com.huaheng.api.U8.domain.ICSWarehouseModel;
import com.huaheng.common.exception.service.ServiceException;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.general.company.domain.WarehouseCompany;
import com.huaheng.pc.general.company.mapper.WarehouseCompanyMapperAuto;
import com.huaheng.pc.general.material.domain.Material;
import com.huaheng.pc.general.material.service.IMaterialService;
import com.huaheng.pc.system.dict.domain.DictData;
import com.huaheng.pc.system.dict.domain.DictType;
import com.huaheng.pc.system.dict.service.IDictDataService;
import com.huaheng.pc.system.dict.service.IDictTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
public class GeneralService {


    @Resource
    private WarehouseCompanyMapperAuto warehouseCompanyMapperAuto;

    @Transactional
    public AjaxResult ICSInventory(ICSInventoryModel iCSInventory)    {
        GeneralApi generalApi = new GeneralApi();
        WarehouseCompany warehouseCompany = new WarehouseCompany();
        warehouseCompany.setCompanyCode(iCSInventory.getCompanyCode());
        List<WarehouseCompany> list = warehouseCompanyMapperAuto.selectListEntityByEqual(warehouseCompany);
        if (list == null || list.size() == 0){
            return AjaxResult.error("系统中没有该货主:"+warehouseCompany.toString()+"  信息,请先录入货主信息!");
        }
        //先查询货主对应的仓库,有几个仓库,就循环几次来添加。
        for (WarehouseCompany item :list ) {

            DictData dictData = new DictData();
            dictData.setDictType("materialType");
            dictData.setWarehouseCode(warehouseCompany.getWarehouseCode());
            dictData.setDictValue(iCSInventory.getcInvCCode());
            dictData.setDictLabel(iCSInventory.getcInvCName());
            dictData.setEnable(true);
            generalApi.dict(dictData);

            Material material = new Material();
            material.setCode(iCSInventory.getcInvCode());
            material.setBarcode(iCSInventory.getcInvCode());
            material.setName(iCSInventory.getcInvName());
            material.setUserDef1(iCSInventory.getcInvAddCode());
            material.setSpecification(iCSInventory.getcInvStd());
            material.setMasterUnit(iCSInventory.getcComUnitName());
            material.setAssistUnit(iCSInventory.getcAssComUnitCode());
            material.setConvertRate(iCSInventory.getfConvertRate());
            material.setType(iCSInventory.getcInvCCode());
            material.setCompanyId(warehouseCompany.getCompanyId());
            material.setCompanyCode(warehouseCompany.getCompanyCode());
            material.setWarehouseId(warehouseCompany.getWarehouseId());
            material.setWarehouseCode(warehouseCompany.getWarehouseCode());
            material.setLastUpdatedBy(ShiroUtils.getLoginName());
            material.setCreatedBy(ShiroUtils.getLoginName());
            material.setLastUpdated(new Date());
            AjaxResult ajaxResult = generalApi.material(material);
        }
        return AjaxResult.success("成功!");
    }

    public AjaxResult ICSWarehouse(ICSWarehouseModel iCSWarehouse)      {
        return AjaxResult.success("成功!");
    }

}