master
erzhongxmu@hotmail.com 2018-10-31 14:52:52 +08:00
parent 856e6ff149
commit c0b36646af
12 changed files with 2105 additions and 205 deletions

View File

@ -0,0 +1,406 @@
package com.zzjee.ba.controller;
import com.zzjee.ba.entity.BaGoodsTypeEntity;
import com.zzjee.ba.service.BaGoodsTypeServiceI;
import java.util.ArrayList;
import java.util.List;
import java.text.SimpleDateFormat;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
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.servlet.ModelAndView;
import org.jeecgframework.core.common.controller.BaseController;
import org.jeecgframework.core.common.exception.BusinessException;
import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery;
import org.jeecgframework.core.common.model.common.TreeChildCount;
import org.jeecgframework.core.common.model.json.AjaxJson;
import org.jeecgframework.core.common.model.json.DataGrid;
import org.jeecgframework.core.constant.Globals;
import org.jeecgframework.core.util.StringUtil;
import org.jeecgframework.tag.core.easyui.TagUtil;
import org.jeecgframework.web.system.pojo.base.TSDepart;
import org.jeecgframework.web.system.service.SystemService;
import org.jeecgframework.core.util.MyBeanUtils;
import java.io.OutputStream;
import org.jeecgframework.core.util.BrowserUtils;
import org.jeecgframework.poi.excel.ExcelExportUtil;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.entity.TemplateExportParams;
import org.jeecgframework.poi.excel.entity.vo.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.vo.TemplateExcelConstants;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.jeecgframework.core.util.ResourceUtil;
import java.io.IOException;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import java.util.Map;
import java.util.HashMap;
import org.jeecgframework.core.util.ExceptionUtil;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
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 org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.jeecgframework.core.beanvalidator.BeanValidators;
import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
import java.net.URI;
import org.springframework.http.MediaType;
import org.springframework.web.util.UriComponentsBuilder;
/**
* @Title: Controller
* @Description:
* @author onlineGenerator
* @date 2018-10-31 12:01:40
* @version V1.0
*
*/
@Controller
@RequestMapping("/baGoodsTypeController")
public class BaGoodsTypeController extends BaseController {
/**
* Logger for this class
*/
private static final Logger logger = Logger.getLogger(BaGoodsTypeController.class);
@Autowired
private BaGoodsTypeServiceI baGoodsTypeService;
@Autowired
private SystemService systemService;
@Autowired
private Validator validator;
/**
*
*
* @return
*/
@RequestMapping(params = "list")
public ModelAndView list(HttpServletRequest request) {
return new ModelAndView("com/zzjee/ba/baGoodsTypeList");
}
/**
* easyui AJAX
*
* @param request
* @param response
* @param dataGrid
* @param user
*/
@RequestMapping(params = "datagrid")
public void datagrid(BaGoodsTypeEntity baGoodsType,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
CriteriaQuery cq = new CriteriaQuery(BaGoodsTypeEntity.class, dataGrid);
//查询条件组装器
org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, baGoodsType, request.getParameterMap());
try{
//自定义追加查询条件
}catch (Exception e) {
throw new BusinessException(e.getMessage());
}
cq.add();
this.baGoodsTypeService.getDataGridReturn(cq, true);
TagUtil.datagrid(response, dataGrid);
}
/**
*
*
* @return
*/
@RequestMapping(params = "doDel")
@ResponseBody
public AjaxJson doDel(BaGoodsTypeEntity baGoodsType, HttpServletRequest request) {
String message = null;
AjaxJson j = new AjaxJson();
baGoodsType = systemService.getEntity(BaGoodsTypeEntity.class, baGoodsType.getId());
message = "产品属性删除成功";
try{
baGoodsTypeService.delete(baGoodsType);
systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
}catch(Exception e){
e.printStackTrace();
message = "产品属性删除失败";
throw new BusinessException(e.getMessage());
}
j.setMsg(message);
return j;
}
/**
*
*
* @return
*/
@RequestMapping(params = "doBatchDel")
@ResponseBody
public AjaxJson doBatchDel(String ids,HttpServletRequest request){
String message = null;
AjaxJson j = new AjaxJson();
message = "产品属性删除成功";
try{
for(String id:ids.split(",")){
BaGoodsTypeEntity baGoodsType = systemService.getEntity(BaGoodsTypeEntity.class,
id
);
baGoodsTypeService.delete(baGoodsType);
systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
}
}catch(Exception e){
e.printStackTrace();
message = "产品属性删除失败";
throw new BusinessException(e.getMessage());
}
j.setMsg(message);
return j;
}
/**
*
*
* @param ids
* @return
*/
@RequestMapping(params = "doAdd")
@ResponseBody
public AjaxJson doAdd(BaGoodsTypeEntity baGoodsType, HttpServletRequest request) {
String message = null;
AjaxJson j = new AjaxJson();
message = "产品属性添加成功";
try{
baGoodsTypeService.save(baGoodsType);
systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
}catch(Exception e){
e.printStackTrace();
message = "产品属性添加失败";
throw new BusinessException(e.getMessage());
}
j.setMsg(message);
return j;
}
/**
*
*
* @param ids
* @return
*/
@RequestMapping(params = "doUpdate")
@ResponseBody
public AjaxJson doUpdate(BaGoodsTypeEntity baGoodsType, HttpServletRequest request) {
String message = null;
AjaxJson j = new AjaxJson();
message = "产品属性更新成功";
BaGoodsTypeEntity t = baGoodsTypeService.get(BaGoodsTypeEntity.class, baGoodsType.getId());
try {
MyBeanUtils.copyBeanNotNull2Bean(baGoodsType, t);
baGoodsTypeService.saveOrUpdate(t);
systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
} catch (Exception e) {
e.printStackTrace();
message = "产品属性更新失败";
throw new BusinessException(e.getMessage());
}
j.setMsg(message);
return j;
}
/**
*
*
* @return
*/
@RequestMapping(params = "goAdd")
public ModelAndView goAdd(BaGoodsTypeEntity baGoodsType, HttpServletRequest req) {
if (StringUtil.isNotEmpty(baGoodsType.getId())) {
baGoodsType = baGoodsTypeService.getEntity(BaGoodsTypeEntity.class, baGoodsType.getId());
req.setAttribute("baGoodsTypePage", baGoodsType);
}
return new ModelAndView("com/zzjee/ba/baGoodsType-add");
}
/**
*
*
* @return
*/
@RequestMapping(params = "goUpdate")
public ModelAndView goUpdate(BaGoodsTypeEntity baGoodsType, HttpServletRequest req) {
if (StringUtil.isNotEmpty(baGoodsType.getId())) {
baGoodsType = baGoodsTypeService.getEntity(BaGoodsTypeEntity.class, baGoodsType.getId());
req.setAttribute("baGoodsTypePage", baGoodsType);
}
return new ModelAndView("com/zzjee/ba/baGoodsType-update");
}
/**
*
*
* @return
*/
@RequestMapping(params = "upload")
public ModelAndView upload(HttpServletRequest req) {
req.setAttribute("controller_name","baGoodsTypeController");
return new ModelAndView("common/upload/pub_excel_upload");
}
/**
* excel
*
* @param request
* @param response
*/
@RequestMapping(params = "exportXls")
public String exportXls(BaGoodsTypeEntity baGoodsType,HttpServletRequest request,HttpServletResponse response
, DataGrid dataGrid,ModelMap modelMap) {
CriteriaQuery cq = new CriteriaQuery(BaGoodsTypeEntity.class, dataGrid);
org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, baGoodsType, request.getParameterMap());
List<BaGoodsTypeEntity> baGoodsTypes = this.baGoodsTypeService.getListByCriteriaQuery(cq,false);
modelMap.put(NormalExcelConstants.FILE_NAME,"产品属性");
modelMap.put(NormalExcelConstants.CLASS,BaGoodsTypeEntity.class);
modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("产品属性列表", "导出人:"+ResourceUtil.getSessionUserName().getRealName(),
"导出信息"));
modelMap.put(NormalExcelConstants.DATA_LIST,baGoodsTypes);
return NormalExcelConstants.JEECG_EXCEL_VIEW;
}
/**
* excel 使
*
* @param request
* @param response
*/
@RequestMapping(params = "exportXlsByT")
public String exportXlsByT(BaGoodsTypeEntity baGoodsType,HttpServletRequest request,HttpServletResponse response
, DataGrid dataGrid,ModelMap modelMap) {
modelMap.put(NormalExcelConstants.FILE_NAME,"产品属性");
modelMap.put(NormalExcelConstants.CLASS,BaGoodsTypeEntity.class);
modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("产品属性列表", "导出人:"+ResourceUtil.getSessionUserName().getRealName(),
"导出信息"));
modelMap.put(NormalExcelConstants.DATA_LIST,new ArrayList());
return NormalExcelConstants.JEECG_EXCEL_VIEW;
}
@SuppressWarnings("unchecked")
@RequestMapping(params = "importExcel", method = RequestMethod.POST)
@ResponseBody
public AjaxJson importExcel(HttpServletRequest request, HttpServletResponse response) {
AjaxJson j = new AjaxJson();
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);
params.setNeedSave(true);
try {
List<BaGoodsTypeEntity> listBaGoodsTypeEntitys = ExcelImportUtil.importExcel(file.getInputStream(),BaGoodsTypeEntity.class,params);
for (BaGoodsTypeEntity baGoodsType : listBaGoodsTypeEntitys) {
baGoodsTypeService.save(baGoodsType);
}
j.setMsg("文件导入成功!");
} catch (Exception e) {
j.setMsg("文件导入失败!");
logger.error(ExceptionUtil.getExceptionMessage(e));
}finally{
try {
file.getInputStream().close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return j;
}
@RequestMapping(method = RequestMethod.GET)
@ResponseBody
public List<BaGoodsTypeEntity> list() {
List<BaGoodsTypeEntity> listBaGoodsTypes=baGoodsTypeService.getList(BaGoodsTypeEntity.class);
return listBaGoodsTypes;
}
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<?> get(@PathVariable("id") String id) {
BaGoodsTypeEntity task = baGoodsTypeService.get(BaGoodsTypeEntity.class, id);
if (task == null) {
return new ResponseEntity(HttpStatus.NOT_FOUND);
}
return new ResponseEntity(task, HttpStatus.OK);
}
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public ResponseEntity<?> create(@RequestBody BaGoodsTypeEntity baGoodsType, UriComponentsBuilder uriBuilder) {
//调用JSR303 Bean Validator进行校验如果出错返回含400错误码及json格式的错误信息.
Set<ConstraintViolation<BaGoodsTypeEntity>> failures = validator.validate(baGoodsType);
if (!failures.isEmpty()) {
return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
}
//保存
try{
baGoodsTypeService.save(baGoodsType);
} catch (Exception e) {
e.printStackTrace();
return new ResponseEntity(HttpStatus.NO_CONTENT);
}
//按照Restful风格约定创建指向新任务的url, 也可以直接返回id或对象.
String id = baGoodsType.getId();
URI uri = uriBuilder.path("/rest/baGoodsTypeController/" + id).build().toUri();
HttpHeaders headers = new HttpHeaders();
headers.setLocation(uri);
return new ResponseEntity(headers, HttpStatus.CREATED);
}
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> update(@RequestBody BaGoodsTypeEntity baGoodsType) {
//调用JSR303 Bean Validator进行校验如果出错返回含400错误码及json格式的错误信息.
Set<ConstraintViolation<BaGoodsTypeEntity>> failures = validator.validate(baGoodsType);
if (!failures.isEmpty()) {
return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
}
//保存
try{
baGoodsTypeService.saveOrUpdate(baGoodsType);
} catch (Exception e) {
e.printStackTrace();
return new ResponseEntity(HttpStatus.NO_CONTENT);
}
//按Restful约定返回204状态码, 无内容. 也可以返回200状态码.
return new ResponseEntity(HttpStatus.NO_CONTENT);
}
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void delete(@PathVariable("id") String id) {
baGoodsTypeService.deleteEntityById(BaGoodsTypeEntity.class, id);
}
}

View File

@ -0,0 +1,406 @@
package com.zzjee.ba.controller;
import com.zzjee.ba.entity.BaUnitEntity;
import com.zzjee.ba.service.BaUnitServiceI;
import java.util.ArrayList;
import java.util.List;
import java.text.SimpleDateFormat;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
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.servlet.ModelAndView;
import org.jeecgframework.core.common.controller.BaseController;
import org.jeecgframework.core.common.exception.BusinessException;
import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery;
import org.jeecgframework.core.common.model.common.TreeChildCount;
import org.jeecgframework.core.common.model.json.AjaxJson;
import org.jeecgframework.core.common.model.json.DataGrid;
import org.jeecgframework.core.constant.Globals;
import org.jeecgframework.core.util.StringUtil;
import org.jeecgframework.tag.core.easyui.TagUtil;
import org.jeecgframework.web.system.pojo.base.TSDepart;
import org.jeecgframework.web.system.service.SystemService;
import org.jeecgframework.core.util.MyBeanUtils;
import java.io.OutputStream;
import org.jeecgframework.core.util.BrowserUtils;
import org.jeecgframework.poi.excel.ExcelExportUtil;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.entity.TemplateExportParams;
import org.jeecgframework.poi.excel.entity.vo.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.vo.TemplateExcelConstants;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.jeecgframework.core.util.ResourceUtil;
import java.io.IOException;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import java.util.Map;
import java.util.HashMap;
import org.jeecgframework.core.util.ExceptionUtil;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
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 org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.jeecgframework.core.beanvalidator.BeanValidators;
import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
import java.net.URI;
import org.springframework.http.MediaType;
import org.springframework.web.util.UriComponentsBuilder;
/**
* @Title: Controller
* @Description:
* @author onlineGenerator
* @date 2018-10-31 12:01:21
* @version V1.0
*
*/
@Controller
@RequestMapping("/baUnitController")
public class BaUnitController extends BaseController {
/**
* Logger for this class
*/
private static final Logger logger = Logger.getLogger(BaUnitController.class);
@Autowired
private BaUnitServiceI baUnitService;
@Autowired
private SystemService systemService;
@Autowired
private Validator validator;
/**
*
*
* @return
*/
@RequestMapping(params = "list")
public ModelAndView list(HttpServletRequest request) {
return new ModelAndView("com/zzjee/ba/baUnitList");
}
/**
* easyui AJAX
*
* @param request
* @param response
* @param dataGrid
* @param user
*/
@RequestMapping(params = "datagrid")
public void datagrid(BaUnitEntity baUnit,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
CriteriaQuery cq = new CriteriaQuery(BaUnitEntity.class, dataGrid);
//查询条件组装器
org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, baUnit, request.getParameterMap());
try{
//自定义追加查询条件
}catch (Exception e) {
throw new BusinessException(e.getMessage());
}
cq.add();
this.baUnitService.getDataGridReturn(cq, true);
TagUtil.datagrid(response, dataGrid);
}
/**
*
*
* @return
*/
@RequestMapping(params = "doDel")
@ResponseBody
public AjaxJson doDel(BaUnitEntity baUnit, HttpServletRequest request) {
String message = null;
AjaxJson j = new AjaxJson();
baUnit = systemService.getEntity(BaUnitEntity.class, baUnit.getId());
message = "计量单位删除成功";
try{
baUnitService.delete(baUnit);
systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
}catch(Exception e){
e.printStackTrace();
message = "计量单位删除失败";
throw new BusinessException(e.getMessage());
}
j.setMsg(message);
return j;
}
/**
*
*
* @return
*/
@RequestMapping(params = "doBatchDel")
@ResponseBody
public AjaxJson doBatchDel(String ids,HttpServletRequest request){
String message = null;
AjaxJson j = new AjaxJson();
message = "计量单位删除成功";
try{
for(String id:ids.split(",")){
BaUnitEntity baUnit = systemService.getEntity(BaUnitEntity.class,
id
);
baUnitService.delete(baUnit);
systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
}
}catch(Exception e){
e.printStackTrace();
message = "计量单位删除失败";
throw new BusinessException(e.getMessage());
}
j.setMsg(message);
return j;
}
/**
*
*
* @param ids
* @return
*/
@RequestMapping(params = "doAdd")
@ResponseBody
public AjaxJson doAdd(BaUnitEntity baUnit, HttpServletRequest request) {
String message = null;
AjaxJson j = new AjaxJson();
message = "计量单位添加成功";
try{
baUnitService.save(baUnit);
systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
}catch(Exception e){
e.printStackTrace();
message = "计量单位添加失败";
throw new BusinessException(e.getMessage());
}
j.setMsg(message);
return j;
}
/**
*
*
* @param ids
* @return
*/
@RequestMapping(params = "doUpdate")
@ResponseBody
public AjaxJson doUpdate(BaUnitEntity baUnit, HttpServletRequest request) {
String message = null;
AjaxJson j = new AjaxJson();
message = "计量单位更新成功";
BaUnitEntity t = baUnitService.get(BaUnitEntity.class, baUnit.getId());
try {
MyBeanUtils.copyBeanNotNull2Bean(baUnit, t);
baUnitService.saveOrUpdate(t);
systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
} catch (Exception e) {
e.printStackTrace();
message = "计量单位更新失败";
throw new BusinessException(e.getMessage());
}
j.setMsg(message);
return j;
}
/**
*
*
* @return
*/
@RequestMapping(params = "goAdd")
public ModelAndView goAdd(BaUnitEntity baUnit, HttpServletRequest req) {
if (StringUtil.isNotEmpty(baUnit.getId())) {
baUnit = baUnitService.getEntity(BaUnitEntity.class, baUnit.getId());
req.setAttribute("baUnitPage", baUnit);
}
return new ModelAndView("com/zzjee/ba/baUnit-add");
}
/**
*
*
* @return
*/
@RequestMapping(params = "goUpdate")
public ModelAndView goUpdate(BaUnitEntity baUnit, HttpServletRequest req) {
if (StringUtil.isNotEmpty(baUnit.getId())) {
baUnit = baUnitService.getEntity(BaUnitEntity.class, baUnit.getId());
req.setAttribute("baUnitPage", baUnit);
}
return new ModelAndView("com/zzjee/ba/baUnit-update");
}
/**
*
*
* @return
*/
@RequestMapping(params = "upload")
public ModelAndView upload(HttpServletRequest req) {
req.setAttribute("controller_name","baUnitController");
return new ModelAndView("common/upload/pub_excel_upload");
}
/**
* excel
*
* @param request
* @param response
*/
@RequestMapping(params = "exportXls")
public String exportXls(BaUnitEntity baUnit,HttpServletRequest request,HttpServletResponse response
, DataGrid dataGrid,ModelMap modelMap) {
CriteriaQuery cq = new CriteriaQuery(BaUnitEntity.class, dataGrid);
org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, baUnit, request.getParameterMap());
List<BaUnitEntity> baUnits = this.baUnitService.getListByCriteriaQuery(cq,false);
modelMap.put(NormalExcelConstants.FILE_NAME,"计量单位");
modelMap.put(NormalExcelConstants.CLASS,BaUnitEntity.class);
modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("计量单位列表", "导出人:"+ResourceUtil.getSessionUserName().getRealName(),
"导出信息"));
modelMap.put(NormalExcelConstants.DATA_LIST,baUnits);
return NormalExcelConstants.JEECG_EXCEL_VIEW;
}
/**
* excel 使
*
* @param request
* @param response
*/
@RequestMapping(params = "exportXlsByT")
public String exportXlsByT(BaUnitEntity baUnit,HttpServletRequest request,HttpServletResponse response
, DataGrid dataGrid,ModelMap modelMap) {
modelMap.put(NormalExcelConstants.FILE_NAME,"计量单位");
modelMap.put(NormalExcelConstants.CLASS,BaUnitEntity.class);
modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("计量单位列表", "导出人:"+ResourceUtil.getSessionUserName().getRealName(),
"导出信息"));
modelMap.put(NormalExcelConstants.DATA_LIST,new ArrayList());
return NormalExcelConstants.JEECG_EXCEL_VIEW;
}
@SuppressWarnings("unchecked")
@RequestMapping(params = "importExcel", method = RequestMethod.POST)
@ResponseBody
public AjaxJson importExcel(HttpServletRequest request, HttpServletResponse response) {
AjaxJson j = new AjaxJson();
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);
params.setNeedSave(true);
try {
List<BaUnitEntity> listBaUnitEntitys = ExcelImportUtil.importExcel(file.getInputStream(),BaUnitEntity.class,params);
for (BaUnitEntity baUnit : listBaUnitEntitys) {
baUnitService.save(baUnit);
}
j.setMsg("文件导入成功!");
} catch (Exception e) {
j.setMsg("文件导入失败!");
logger.error(ExceptionUtil.getExceptionMessage(e));
}finally{
try {
file.getInputStream().close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return j;
}
@RequestMapping(method = RequestMethod.GET)
@ResponseBody
public List<BaUnitEntity> list() {
List<BaUnitEntity> listBaUnits=baUnitService.getList(BaUnitEntity.class);
return listBaUnits;
}
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<?> get(@PathVariable("id") String id) {
BaUnitEntity task = baUnitService.get(BaUnitEntity.class, id);
if (task == null) {
return new ResponseEntity(HttpStatus.NOT_FOUND);
}
return new ResponseEntity(task, HttpStatus.OK);
}
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public ResponseEntity<?> create(@RequestBody BaUnitEntity baUnit, UriComponentsBuilder uriBuilder) {
//调用JSR303 Bean Validator进行校验如果出错返回含400错误码及json格式的错误信息.
Set<ConstraintViolation<BaUnitEntity>> failures = validator.validate(baUnit);
if (!failures.isEmpty()) {
return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
}
//保存
try{
baUnitService.save(baUnit);
} catch (Exception e) {
e.printStackTrace();
return new ResponseEntity(HttpStatus.NO_CONTENT);
}
//按照Restful风格约定创建指向新任务的url, 也可以直接返回id或对象.
String id = baUnit.getId();
URI uri = uriBuilder.path("/rest/baUnitController/" + id).build().toUri();
HttpHeaders headers = new HttpHeaders();
headers.setLocation(uri);
return new ResponseEntity(headers, HttpStatus.CREATED);
}
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> update(@RequestBody BaUnitEntity baUnit) {
//调用JSR303 Bean Validator进行校验如果出错返回含400错误码及json格式的错误信息.
Set<ConstraintViolation<BaUnitEntity>> failures = validator.validate(baUnit);
if (!failures.isEmpty()) {
return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
}
//保存
try{
baUnitService.saveOrUpdate(baUnit);
} catch (Exception e) {
e.printStackTrace();
return new ResponseEntity(HttpStatus.NO_CONTENT);
}
//按Restful约定返回204状态码, 无内容. 也可以返回200状态码.
return new ResponseEntity(HttpStatus.NO_CONTENT);
}
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void delete(@PathVariable("id") String id) {
baUnitService.deleteEntityById(BaUnitEntity.class, id);
}
}

View File

@ -0,0 +1,237 @@
package com.zzjee.ba.entity;
import java.math.BigDecimal;
import java.util.Date;
import java.lang.String;
import java.lang.Double;
import java.lang.Integer;
import java.math.BigDecimal;
import javax.xml.soap.Text;
import java.sql.Blob;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.SequenceGenerator;
import org.jeecgframework.poi.excel.annotation.Excel;
/**
* @Title: Entity
* @Description:
* @author onlineGenerator
* @date 2018-10-31 12:01:40
* @version V1.0
*
*/
@Entity
@Table(name = "ba_goods_type", schema = "")
@SuppressWarnings("serial")
public class BaGoodsTypeEntity implements java.io.Serializable {
/**主键*/
private String id;
/**创建人名称*/
private String createName;
/**创建人登录名称*/
private String createBy;
/**创建日期*/
private Date createDate;
/**更新人名称*/
private String updateName;
/**更新人登录名称*/
private String updateBy;
/**更新日期*/
private Date updateDate;
/**所属部门*/
private String sysOrgCode;
/**所属公司*/
private String sysCompanyCode;
/**产品属性编码*/
@Excel(name="产品属性编码")
private String goodsTypeCode;
/**产品属性名称*/
@Excel(name="产品属性名称")
private String goodsTypeName;
/**
*: java.lang.String
*@return: java.lang.String
*/
@Id
@GeneratedValue(generator = "paymentableGenerator")
@GenericGenerator(name = "paymentableGenerator", strategy = "uuid")
@Column(name ="ID",nullable=false,length=36)
public String getId(){
return this.id;
}
/**
*: java.lang.String
*@param: java.lang.String
*/
public void setId(String id){
this.id = id;
}
/**
*: java.lang.String
*@return: java.lang.String
*/
@Column(name ="CREATE_NAME",nullable=true,length=50)
public String getCreateName(){
return this.createName;
}
/**
*: java.lang.String
*@param: java.lang.String
*/
public void setCreateName(String createName){
this.createName = createName;
}
/**
*: java.lang.String
*@return: java.lang.String
*/
@Column(name ="CREATE_BY",nullable=true,length=50)
public String getCreateBy(){
return this.createBy;
}
/**
*: java.lang.String
*@param: java.lang.String
*/
public void setCreateBy(String createBy){
this.createBy = createBy;
}
/**
*: java.util.Date
*@return: java.util.Date
*/
@Column(name ="CREATE_DATE",nullable=true,length=20)
public Date getCreateDate(){
return this.createDate;
}
/**
*: java.util.Date
*@param: java.util.Date
*/
public void setCreateDate(Date createDate){
this.createDate = createDate;
}
/**
*: java.lang.String
*@return: java.lang.String
*/
@Column(name ="UPDATE_NAME",nullable=true,length=50)
public String getUpdateName(){
return this.updateName;
}
/**
*: java.lang.String
*@param: java.lang.String
*/
public void setUpdateName(String updateName){
this.updateName = updateName;
}
/**
*: java.lang.String
*@return: java.lang.String
*/
@Column(name ="UPDATE_BY",nullable=true,length=50)
public String getUpdateBy(){
return this.updateBy;
}
/**
*: java.lang.String
*@param: java.lang.String
*/
public void setUpdateBy(String updateBy){
this.updateBy = updateBy;
}
/**
*: java.util.Date
*@return: java.util.Date
*/
@Column(name ="UPDATE_DATE",nullable=true,length=20)
public Date getUpdateDate(){
return this.updateDate;
}
/**
*: java.util.Date
*@param: java.util.Date
*/
public void setUpdateDate(Date updateDate){
this.updateDate = updateDate;
}
/**
*: java.lang.String
*@return: java.lang.String
*/
@Column(name ="SYS_ORG_CODE",nullable=true,length=50)
public String getSysOrgCode(){
return this.sysOrgCode;
}
/**
*: java.lang.String
*@param: java.lang.String
*/
public void setSysOrgCode(String sysOrgCode){
this.sysOrgCode = sysOrgCode;
}
/**
*: java.lang.String
*@return: java.lang.String
*/
@Column(name ="SYS_COMPANY_CODE",nullable=true,length=50)
public String getSysCompanyCode(){
return this.sysCompanyCode;
}
/**
*: java.lang.String
*@param: java.lang.String
*/
public void setSysCompanyCode(String sysCompanyCode){
this.sysCompanyCode = sysCompanyCode;
}
/**
*: java.lang.String
*@return: java.lang.String
*/
@Column(name ="GOODS_TYPE_CODE",nullable=true,length=32)
public String getGoodsTypeCode(){
return this.goodsTypeCode;
}
/**
*: java.lang.String
*@param: java.lang.String
*/
public void setGoodsTypeCode(String goodsTypeCode){
this.goodsTypeCode = goodsTypeCode;
}
/**
*: java.lang.String
*@return: java.lang.String
*/
@Column(name ="GOODS_TYPE_NAME",nullable=true,length=32)
public String getGoodsTypeName(){
return this.goodsTypeName;
}
/**
*: java.lang.String
*@param: java.lang.String
*/
public void setGoodsTypeName(String goodsTypeName){
this.goodsTypeName = goodsTypeName;
}
}

View File

@ -0,0 +1,310 @@
package com.zzjee.ba.entity;
import java.math.BigDecimal;
import java.util.Date;
import java.lang.String;
import java.lang.Double;
import java.lang.Integer;
import java.math.BigDecimal;
import javax.xml.soap.Text;
import java.sql.Blob;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.SequenceGenerator;
import org.jeecgframework.poi.excel.annotation.Excel;
/**
* @Title: Entity
* @Description:
* @author onlineGenerator
* @date 2018-10-31 12:01:21
* @version V1.0
*
*/
@Entity
@Table(name = "ba_unit", schema = "")
@SuppressWarnings("serial")
public class BaUnitEntity implements java.io.Serializable {
/**主键*/
private String id;
/**创建人名称*/
private String createName;
/**创建人登录名称*/
private String createBy;
/**创建日期*/
private Date createDate;
/**更新人名称*/
private String updateName;
/**更新人登录名称*/
private String updateBy;
/**更新日期*/
private Date updateDate;
/**所属部门*/
private String sysOrgCode;
/**所属公司*/
private String sysCompanyCode;
/**单位代码*/
@Excel(name="单位代码")
private String unitCode;
/**单位名称*/
@Excel(name="单位名称")
private String unitZhName;
/**英文名称*/
@Excel(name="英文名称")
private String unitEnName;
/**国际度量衡换算值*/
private String unitChange;
/**单位类型*/
private String unitType;
/**停用*/
private String unitDel;
/**
*: java.lang.String
*@return: java.lang.String
*/
@Id
@GeneratedValue(generator = "paymentableGenerator")
@GenericGenerator(name = "paymentableGenerator", strategy = "uuid")
@Column(name ="ID",nullable=false,length=36)
public String getId(){
return this.id;
}
/**
*: java.lang.String
*@param: java.lang.String
*/
public void setId(String id){
this.id = id;
}
/**
*: java.lang.String
*@return: java.lang.String
*/
@Column(name ="CREATE_NAME",nullable=true,length=50)
public String getCreateName(){
return this.createName;
}
/**
*: java.lang.String
*@param: java.lang.String
*/
public void setCreateName(String createName){
this.createName = createName;
}
/**
*: java.lang.String
*@return: java.lang.String
*/
@Column(name ="CREATE_BY",nullable=true,length=50)
public String getCreateBy(){
return this.createBy;
}
/**
*: java.lang.String
*@param: java.lang.String
*/
public void setCreateBy(String createBy){
this.createBy = createBy;
}
/**
*: java.util.Date
*@return: java.util.Date
*/
@Column(name ="CREATE_DATE",nullable=true,length=20)
public Date getCreateDate(){
return this.createDate;
}
/**
*: java.util.Date
*@param: java.util.Date
*/
public void setCreateDate(Date createDate){
this.createDate = createDate;
}
/**
*: java.lang.String
*@return: java.lang.String
*/
@Column(name ="UPDATE_NAME",nullable=true,length=50)
public String getUpdateName(){
return this.updateName;
}
/**
*: java.lang.String
*@param: java.lang.String
*/
public void setUpdateName(String updateName){
this.updateName = updateName;
}
/**
*: java.lang.String
*@return: java.lang.String
*/
@Column(name ="UPDATE_BY",nullable=true,length=50)
public String getUpdateBy(){
return this.updateBy;
}
/**
*: java.lang.String
*@param: java.lang.String
*/
public void setUpdateBy(String updateBy){
this.updateBy = updateBy;
}
/**
*: java.util.Date
*@return: java.util.Date
*/
@Column(name ="UPDATE_DATE",nullable=true,length=20)
public Date getUpdateDate(){
return this.updateDate;
}
/**
*: java.util.Date
*@param: java.util.Date
*/
public void setUpdateDate(Date updateDate){
this.updateDate = updateDate;
}
/**
*: java.lang.String
*@return: java.lang.String
*/
@Column(name ="SYS_ORG_CODE",nullable=true,length=50)
public String getSysOrgCode(){
return this.sysOrgCode;
}
/**
*: java.lang.String
*@param: java.lang.String
*/
public void setSysOrgCode(String sysOrgCode){
this.sysOrgCode = sysOrgCode;
}
/**
*: java.lang.String
*@return: java.lang.String
*/
@Column(name ="SYS_COMPANY_CODE",nullable=true,length=50)
public String getSysCompanyCode(){
return this.sysCompanyCode;
}
/**
*: java.lang.String
*@param: java.lang.String
*/
public void setSysCompanyCode(String sysCompanyCode){
this.sysCompanyCode = sysCompanyCode;
}
/**
*: java.lang.String
*@return: java.lang.String
*/
@Column(name ="UNIT_CODE",nullable=true,length=32)
public String getUnitCode(){
return this.unitCode;
}
/**
*: java.lang.String
*@param: java.lang.String
*/
public void setUnitCode(String unitCode){
this.unitCode = unitCode;
}
/**
*: java.lang.String
*@return: java.lang.String
*/
@Column(name ="UNIT_ZH_NAME",nullable=true,length=32)
public String getUnitZhName(){
return this.unitZhName;
}
/**
*: java.lang.String
*@param: java.lang.String
*/
public void setUnitZhName(String unitZhName){
this.unitZhName = unitZhName;
}
/**
*: java.lang.String
*@return: java.lang.String
*/
@Column(name ="UNIT_EN_NAME",nullable=true,length=32)
public String getUnitEnName(){
return this.unitEnName;
}
/**
*: java.lang.String
*@param: java.lang.String
*/
public void setUnitEnName(String unitEnName){
this.unitEnName = unitEnName;
}
/**
*: java.lang.String
*@return: java.lang.String
*/
@Column(name ="UNIT_CHANGE",nullable=true,length=32)
public String getUnitChange(){
return this.unitChange;
}
/**
*: java.lang.String
*@param: java.lang.String
*/
public void setUnitChange(String unitChange){
this.unitChange = unitChange;
}
/**
*: java.lang.String
*@return: java.lang.String
*/
@Column(name ="UNIT_TYPE",nullable=true,length=32)
public String getUnitType(){
return this.unitType;
}
/**
*: java.lang.String
*@param: java.lang.String
*/
public void setUnitType(String unitType){
this.unitType = unitType;
}
/**
*: java.lang.String
*@return: java.lang.String
*/
@Column(name ="UNIT_DEL",nullable=true,length=32)
public String getUnitDel(){
return this.unitDel;
}
/**
*: java.lang.String
*@param: java.lang.String
*/
public void setUnitDel(String unitDel){
this.unitDel = unitDel;
}
}

View File

@ -0,0 +1,15 @@
package com.zzjee.ba.service;
import com.zzjee.ba.entity.BaGoodsTypeEntity;
import org.jeecgframework.core.common.service.CommonService;
import java.io.Serializable;
public interface BaGoodsTypeServiceI extends CommonService{
public void delete(BaGoodsTypeEntity entity) throws Exception;
public Serializable save(BaGoodsTypeEntity entity) throws Exception;
public void saveOrUpdate(BaGoodsTypeEntity entity) throws Exception;
}

View File

@ -0,0 +1,15 @@
package com.zzjee.ba.service;
import com.zzjee.ba.entity.BaUnitEntity;
import org.jeecgframework.core.common.service.CommonService;
import java.io.Serializable;
public interface BaUnitServiceI extends CommonService{
public void delete(BaUnitEntity entity) throws Exception;
public Serializable save(BaUnitEntity entity) throws Exception;
public void saveOrUpdate(BaUnitEntity entity) throws Exception;
}

View File

@ -0,0 +1,138 @@
package com.zzjee.ba.service.impl;
import com.zzjee.ba.service.BaGoodsTypeServiceI;
import org.jeecgframework.core.common.service.impl.CommonServiceImpl;
import com.zzjee.ba.entity.BaGoodsTypeEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.io.Serializable;
import org.jeecgframework.core.util.ApplicationContextUtil;
import org.jeecgframework.core.util.MyClassLoader;
import org.jeecgframework.core.util.StringUtil;
import org.jeecgframework.web.cgform.enhance.CgformEnhanceJavaInter;
@Service("baGoodsTypeService")
@Transactional
public class BaGoodsTypeServiceImpl extends CommonServiceImpl implements BaGoodsTypeServiceI {
public void delete(BaGoodsTypeEntity entity) throws Exception{
super.delete(entity);
//执行删除操作增强业务
this.doDelBus(entity);
}
public Serializable save(BaGoodsTypeEntity entity) throws Exception{
Serializable t = super.save(entity);
//执行新增操作增强业务
this.doAddBus(entity);
return t;
}
public void saveOrUpdate(BaGoodsTypeEntity entity) throws Exception{
super.saveOrUpdate(entity);
//执行更新操作增强业务
this.doUpdateBus(entity);
}
/**
*
* @param t
* @return
*/
private void doAddBus(BaGoodsTypeEntity t) throws Exception{
//-----------------sql增强 start----------------------------
//-----------------sql增强 end------------------------------
//-----------------java增强 start---------------------------
//-----------------java增强 end-----------------------------
}
/**
*
* @param t
* @return
*/
private void doUpdateBus(BaGoodsTypeEntity t) throws Exception{
//-----------------sql增强 start----------------------------
//-----------------sql增强 end------------------------------
//-----------------java增强 start---------------------------
//-----------------java增强 end-----------------------------
}
/**
*
* @param id
* @return
*/
private void doDelBus(BaGoodsTypeEntity t) throws Exception{
//-----------------sql增强 start----------------------------
//-----------------sql增强 end------------------------------
//-----------------java增强 start---------------------------
//-----------------java增强 end-----------------------------
}
private Map<String,Object> populationMap(BaGoodsTypeEntity t){
Map<String,Object> map = new HashMap<String,Object>();
map.put("id", t.getId());
map.put("create_name", t.getCreateName());
map.put("create_by", t.getCreateBy());
map.put("create_date", t.getCreateDate());
map.put("update_name", t.getUpdateName());
map.put("update_by", t.getUpdateBy());
map.put("update_date", t.getUpdateDate());
map.put("sys_org_code", t.getSysOrgCode());
map.put("sys_company_code", t.getSysCompanyCode());
map.put("goods_type_code", t.getGoodsTypeCode());
map.put("goods_type_name", t.getGoodsTypeName());
return map;
}
/**
* sql
* @param sql
* @param t
* @return
*/
public String replaceVal(String sql,BaGoodsTypeEntity t){
sql = sql.replace("#{id}",String.valueOf(t.getId()));
sql = sql.replace("#{create_name}",String.valueOf(t.getCreateName()));
sql = sql.replace("#{create_by}",String.valueOf(t.getCreateBy()));
sql = sql.replace("#{create_date}",String.valueOf(t.getCreateDate()));
sql = sql.replace("#{update_name}",String.valueOf(t.getUpdateName()));
sql = sql.replace("#{update_by}",String.valueOf(t.getUpdateBy()));
sql = sql.replace("#{update_date}",String.valueOf(t.getUpdateDate()));
sql = sql.replace("#{sys_org_code}",String.valueOf(t.getSysOrgCode()));
sql = sql.replace("#{sys_company_code}",String.valueOf(t.getSysCompanyCode()));
sql = sql.replace("#{goods_type_code}",String.valueOf(t.getGoodsTypeCode()));
sql = sql.replace("#{goods_type_name}",String.valueOf(t.getGoodsTypeName()));
sql = sql.replace("#{UUID}",UUID.randomUUID().toString());
return sql;
}
/**
* JAVA
*/
private void executeJavaExtend(String cgJavaType,String cgJavaValue,Map<String,Object> data) throws Exception {
if(StringUtil.isNotEmpty(cgJavaValue)){
Object obj = null;
try {
if("class".equals(cgJavaType)){
//因新增时已经校验了实例化是否可以成功,所以这块就不需要再做一次判断
obj = MyClassLoader.getClassByScn(cgJavaValue).newInstance();
}else if("spring".equals(cgJavaType)){
obj = ApplicationContextUtil.getContext().getBean(cgJavaValue);
}
if(obj instanceof CgformEnhanceJavaInter){
CgformEnhanceJavaInter javaInter = (CgformEnhanceJavaInter) obj;
javaInter.execute("ba_goods_type",data);
}
} catch (Exception e) {
e.printStackTrace();
throw new Exception("执行JAVA增强出现异常");
}
}
}
}

View File

@ -0,0 +1,146 @@
package com.zzjee.ba.service.impl;
import com.zzjee.ba.service.BaUnitServiceI;
import org.jeecgframework.core.common.service.impl.CommonServiceImpl;
import com.zzjee.ba.entity.BaUnitEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.io.Serializable;
import org.jeecgframework.core.util.ApplicationContextUtil;
import org.jeecgframework.core.util.MyClassLoader;
import org.jeecgframework.core.util.StringUtil;
import org.jeecgframework.web.cgform.enhance.CgformEnhanceJavaInter;
@Service("baUnitService")
@Transactional
public class BaUnitServiceImpl extends CommonServiceImpl implements BaUnitServiceI {
public void delete(BaUnitEntity entity) throws Exception{
super.delete(entity);
//执行删除操作增强业务
this.doDelBus(entity);
}
public Serializable save(BaUnitEntity entity) throws Exception{
Serializable t = super.save(entity);
//执行新增操作增强业务
this.doAddBus(entity);
return t;
}
public void saveOrUpdate(BaUnitEntity entity) throws Exception{
super.saveOrUpdate(entity);
//执行更新操作增强业务
this.doUpdateBus(entity);
}
/**
*
* @param t
* @return
*/
private void doAddBus(BaUnitEntity t) throws Exception{
//-----------------sql增强 start----------------------------
//-----------------sql增强 end------------------------------
//-----------------java增强 start---------------------------
//-----------------java增强 end-----------------------------
}
/**
*
* @param t
* @return
*/
private void doUpdateBus(BaUnitEntity t) throws Exception{
//-----------------sql增强 start----------------------------
//-----------------sql增强 end------------------------------
//-----------------java增强 start---------------------------
//-----------------java增强 end-----------------------------
}
/**
*
* @param id
* @return
*/
private void doDelBus(BaUnitEntity t) throws Exception{
//-----------------sql增强 start----------------------------
//-----------------sql增强 end------------------------------
//-----------------java增强 start---------------------------
//-----------------java增强 end-----------------------------
}
private Map<String,Object> populationMap(BaUnitEntity t){
Map<String,Object> map = new HashMap<String,Object>();
map.put("id", t.getId());
map.put("create_name", t.getCreateName());
map.put("create_by", t.getCreateBy());
map.put("create_date", t.getCreateDate());
map.put("update_name", t.getUpdateName());
map.put("update_by", t.getUpdateBy());
map.put("update_date", t.getUpdateDate());
map.put("sys_org_code", t.getSysOrgCode());
map.put("sys_company_code", t.getSysCompanyCode());
map.put("unit_code", t.getUnitCode());
map.put("unit_zh_name", t.getUnitZhName());
map.put("unit_en_name", t.getUnitEnName());
map.put("unit_change", t.getUnitChange());
map.put("unit_type", t.getUnitType());
map.put("unit_del", t.getUnitDel());
return map;
}
/**
* sql
* @param sql
* @param t
* @return
*/
public String replaceVal(String sql,BaUnitEntity t){
sql = sql.replace("#{id}",String.valueOf(t.getId()));
sql = sql.replace("#{create_name}",String.valueOf(t.getCreateName()));
sql = sql.replace("#{create_by}",String.valueOf(t.getCreateBy()));
sql = sql.replace("#{create_date}",String.valueOf(t.getCreateDate()));
sql = sql.replace("#{update_name}",String.valueOf(t.getUpdateName()));
sql = sql.replace("#{update_by}",String.valueOf(t.getUpdateBy()));
sql = sql.replace("#{update_date}",String.valueOf(t.getUpdateDate()));
sql = sql.replace("#{sys_org_code}",String.valueOf(t.getSysOrgCode()));
sql = sql.replace("#{sys_company_code}",String.valueOf(t.getSysCompanyCode()));
sql = sql.replace("#{unit_code}",String.valueOf(t.getUnitCode()));
sql = sql.replace("#{unit_zh_name}",String.valueOf(t.getUnitZhName()));
sql = sql.replace("#{unit_en_name}",String.valueOf(t.getUnitEnName()));
sql = sql.replace("#{unit_change}",String.valueOf(t.getUnitChange()));
sql = sql.replace("#{unit_type}",String.valueOf(t.getUnitType()));
sql = sql.replace("#{unit_del}",String.valueOf(t.getUnitDel()));
sql = sql.replace("#{UUID}",UUID.randomUUID().toString());
return sql;
}
/**
* JAVA
*/
private void executeJavaExtend(String cgJavaType,String cgJavaValue,Map<String,Object> data) throws Exception {
if(StringUtil.isNotEmpty(cgJavaValue)){
Object obj = null;
try {
if("class".equals(cgJavaType)){
//因新增时已经校验了实例化是否可以成功,所以这块就不需要再做一次判断
obj = MyClassLoader.getClassByScn(cgJavaValue).newInstance();
}else if("spring".equals(cgJavaType)){
obj = ApplicationContextUtil.getContext().getBean(cgJavaValue);
}
if(obj instanceof CgformEnhanceJavaInter){
CgformEnhanceJavaInter javaInter = (CgformEnhanceJavaInter) obj;
javaInter.execute("ba_unit",data);
}
} catch (Exception e) {
e.printStackTrace();
throw new Exception("执行JAVA增强出现异常");
}
}
}
}

View File

@ -17,6 +17,7 @@ import com.zzjee.wm.entity.WmToDownGoodsEntity;
import com.zzjee.wmapi.entity.WvGiEntity;
import com.zzjee.wmutil.wmIntUtil;
import com.zzjee.wmutil.wmUtil;
import com.zzjee.wmutil.yyUtil;
import org.apache.log4j.Logger;
import org.jeecgframework.core.util.*;
import org.springframework.beans.factory.annotation.Autowired;
@ -260,10 +261,19 @@ public class MdGoodsController extends BaseController {
message = "商品信息读取成功";
try {
if(StringUtil.isEmpty(formDate)){
formDate = "2011-01-01";
if ("U8".equals(ResourceUtil.getConfigByName("interfacetype"))){
yyUtil.getProduct();
}
wmIntUtil.getproduct(formDate);
if ("UAS".equals(ResourceUtil.getConfigByName("interfacetype"))){
if(StringUtil.isEmpty(formDate)){
formDate = "2011-01-01";
}
wmIntUtil.getproduct(formDate);
}
systemService.addLog(message, Globals.Log_Type_UPDATE,
Globals.Log_Leavel_INFO);
} catch (Exception e) {

View File

@ -19,10 +19,7 @@ import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.zzjee.wmutil.billResult;
import com.zzjee.wmutil.resResult;
import com.zzjee.wmutil.wmIntUtil;
import com.zzjee.wmutil.wmUtil;
import com.zzjee.wmutil.*;
import net.sf.json.JSONArray;
import org.apache.log4j.Logger;
import org.apache.poi.hssf.usermodel.HSSFCell;
@ -1669,77 +1666,87 @@ public class WmImNoticeHController extends BaseController {
String message = null;
AjaxJson j = new AjaxJson();
message = "读取成功";
String masterbill[] = {"XKN_TEST","XKN_TEST"};
for(int m =0;m<masterbill.length;m++) {
try {
if (StringUtil.isEmpty(formDate)) {
formDate = "2011-01-01";
}
String master = masterbill[m];
String billclass[] = {"采购验收单", "销售退货单", "其它入库单", "其它采购入库单"};
for (int i = 0; i < billclass.length; i++) {
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("lastUpdateTime", formDate);
paramMap.put("pi_class", billclass[i]);
paramMap.put("master", master);
if ("U8".equals(ResourceUtil.getConfigByName("interfacetype"))){
if(StringUtil.isEmpty(formDate)){
formDate = "2011-01-01";
}
yyUtil.getPo(formDate);
billResult billResult = wmIntUtil.getBillin(paramMap);
for (int s = 0; s < billResult.getData().size(); s++) {
String imcuscode = billResult.getData().get(s).getPiInoutno();
if (StringUtil.isNotEmpty(imcuscode)) {
WmImNoticeHEntity wmimh = systemService.findUniqueByProperty(WmImNoticeHEntity.class, "imCusCode", imcuscode);
if (wmimh == null) {
WmImNoticeHEntity wmImNoticeH = new WmImNoticeHEntity();
List<WmImNoticeIEntity> wmImNoticeIListnew = new ArrayList<WmImNoticeIEntity>();
Map<String, Object> countMap = systemService
.findOneForJdbc("SELECT count(*)+1 as count FROM wm_im_notice_h t where TO_DAYS(t.create_date) = TO_DAYS(NOW());");
}
if ("UAS".equals(ResourceUtil.getConfigByName("interfacetype"))){
String masterbill[] = {"XKN_TEST","XKN_TEST"};
for(int m =0;m<masterbill.length;m++) {
try {
if (StringUtil.isEmpty(formDate)) {
formDate = "2011-01-01";
}
String master = masterbill[m];
String billclass[] = {"采购验收单", "销售退货单", "其它入库单", "其它采购入库单"};
for (int i = 0; i < billclass.length; i++) {
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("lastUpdateTime", formDate);
paramMap.put("pi_class", billclass[i]);
paramMap.put("master", master);
wmImNoticeH.setOrderTypeCode("01");
String noticeid = getNextNoticeid(wmImNoticeH.getOrderTypeCode());
billResult billResult = wmIntUtil.getBillin(paramMap);
for (int s = 0; s < billResult.getData().size(); s++) {
String imcuscode = billResult.getData().get(s).getPiInoutno();
if (StringUtil.isNotEmpty(imcuscode)) {
WmImNoticeHEntity wmimh = systemService.findUniqueByProperty(WmImNoticeHEntity.class, "imCusCode", imcuscode);
if (wmimh == null) {
WmImNoticeHEntity wmImNoticeH = new WmImNoticeHEntity();
List<WmImNoticeIEntity> wmImNoticeIListnew = new ArrayList<WmImNoticeIEntity>();
wmImNoticeH.setCusCode(ResourceUtil.getConfigByName("uas.cuscode"));
wmImNoticeH.setNoticeId(noticeid);
wmImNoticeH.setPlatformCode(Integer.toString(billResult.getData().get(s).getPiId()));
wmImNoticeH.setPiClass(billResult.getData().get(s).getPiClass());
wmImNoticeH.setPiMaster(master);
wmImNoticeH.setSupCode(billResult.getData().get(s).getPiCardcode());
MdSupEntity mdsup = systemService.findUniqueByProperty(MdSupEntity.class, "gysBianMa", wmImNoticeH.getSupCode());
if (mdsup != null) {
wmImNoticeH.setSupName(mdsup.getZhongWenQch());
}
wmImNoticeH.setImCusCode(imcuscode);
wmImNoticeH.setSupName(billResult.getData().get(s).getPiReceivename());
for (int k = 0; k < billResult.getData().get(s).getDetail().size(); k++) {
WmImNoticeIEntity wmi = new WmImNoticeIEntity();
wmi.setGoodsCode(billResult.getData().get(s).getDetail().get(k).getPdProdcode());
MvGoodsEntity mvgoods = systemService.findUniqueByProperty(
MvGoodsEntity.class, "goodsCode", wmi.getGoodsCode());
if (mvgoods != null) {
wmi.setGoodsName(mvgoods.getGoodsName());
wmi.setGoodsUnit(mvgoods.getShlDanWei());
}
wmi.setGoodsCount(Integer.toString(billResult.getData().get(s).getDetail().get(k).getPdInqty()));
wmImNoticeH.setOrderTypeCode("01");
String noticeid = getNextNoticeid(wmImNoticeH.getOrderTypeCode());
wmImNoticeH.setCusCode(ResourceUtil.getConfigByName("uas.cuscode"));
wmImNoticeH.setNoticeId(noticeid);
wmImNoticeH.setPlatformCode(Integer.toString(billResult.getData().get(s).getPiId()));
wmImNoticeH.setPiClass(billResult.getData().get(s).getPiClass());
wmImNoticeH.setPiMaster(master);
wmImNoticeH.setSupCode(billResult.getData().get(s).getPiCardcode());
MdSupEntity mdsup = systemService.findUniqueByProperty(MdSupEntity.class, "gysBianMa", wmImNoticeH.getSupCode());
if (mdsup != null) {
wmImNoticeH.setSupName(mdsup.getZhongWenQch());
}
wmImNoticeH.setImCusCode(imcuscode);
wmImNoticeH.setSupName(billResult.getData().get(s).getPiReceivename());
for (int k = 0; k < billResult.getData().get(s).getDetail().size(); k++) {
WmImNoticeIEntity wmi = new WmImNoticeIEntity();
wmi.setGoodsCode(billResult.getData().get(s).getDetail().get(k).getPdProdcode());
MvGoodsEntity mvgoods = systemService.findUniqueByProperty(
MvGoodsEntity.class, "goodsCode", wmi.getGoodsCode());
if (mvgoods != null) {
wmi.setGoodsName(mvgoods.getGoodsName());
wmi.setGoodsUnit(mvgoods.getShlDanWei());
}
wmi.setGoodsCount(Integer.toString(billResult.getData().get(s).getDetail().get(k).getPdInqty()));
// wmi.setGoodsPrdData(billResult.getData().get(s).getDetail().get(k).getPdProdmadedate2User());
wmi.setOtherId(Integer.toString(billResult.getData().get(s).getDetail().get(k).getPdPdno()));
wmImNoticeIListnew.add(wmi);
}
wmImNoticeHService.addMain(wmImNoticeH, wmImNoticeIListnew);
}
} else {
continue;
}
}
}
wmi.setOtherId(Integer.toString(billResult.getData().get(s).getDetail().get(k).getPdPdno()));
wmImNoticeIListnew.add(wmi);
}
wmImNoticeHService.addMain(wmImNoticeH, wmImNoticeIListnew);
}
} else {
continue;
}
}
}
systemService.addLog(message, Globals.Log_Type_UPDATE,
Globals.Log_Leavel_INFO);
} catch (Exception e) {
e.printStackTrace();
message = "读取失败";
throw new BusinessException(e.getMessage());
}
}
}
systemService.addLog(message, Globals.Log_Type_UPDATE,
Globals.Log_Leavel_INFO);
} catch (Exception e) {
e.printStackTrace();
message = "读取失败";
throw new BusinessException(e.getMessage());
}
}
j.setMsg(message);
return j;
}

View File

@ -325,7 +325,7 @@ public class WmInQmIController extends BaseController {
j.setMsg("不存在此商品");
} else {
mdgoods.setChlShl("0");
Long goodsno = (long) 0;
Double goodsno = 0.00;
System.out
.println("*******************8"
+ oConvertUtils.getString(request
@ -340,10 +340,10 @@ public class WmInQmIController extends BaseController {
oConvertUtils.getString(request
.getParameter("goodsid")));// 获取行项目
for (WmImNoticeIEntity wmImNoticeIEntity : wmImNoticeIEntityList) {
goodsno = Long.parseLong(wmImNoticeIEntity.getGoodsCount())
- Long.parseLong(wmImNoticeIEntity.getGoodsQmCount());
goodsno = Double.parseDouble(wmImNoticeIEntity.getGoodsCount())
- Double.parseDouble(wmImNoticeIEntity.getGoodsQmCount());
if (goodsno > 0) {
Long quat1 =Long.parseLong(mvgoods.getMpCengGao()) * Long.parseLong(mvgoods.getMpDanCeng());
Double quat1 =Double.parseDouble(mvgoods.getMpCengGao()) * Double.parseDouble(mvgoods.getMpDanCeng());
if(quat1 < goodsno){
goodsno = quat1;
}
@ -399,7 +399,9 @@ public class WmInQmIController extends BaseController {
// return j;
// }
}else{
wmInQmI.setTinId(ResourceUtil.getConfigByName("tuopanma"));
if (StringUtil.isEmpty(wmInQmI.getTinId())){
wmInQmI.setTinId(ResourceUtil.getConfigByName("tuopanma"));
}
}
//托盘占用判断

View File

@ -2,15 +2,24 @@ package com.zzjee.wmutil;
import com.alibaba.fastjson.JSONObject;
import com.xiaoleilu.hutool.http.HttpUtil;
import com.zzjee.ba.entity.BaGoodsTypeEntity;
import com.zzjee.ba.entity.BaUnitEntity;
import com.zzjee.md.entity.MdGoodsEntity;
import com.zzjee.md.entity.MdSupEntity;
import com.zzjee.md.entity.MvGoodsEntity;
import com.zzjee.wm.entity.WmImNoticeHEntity;
import com.zzjee.wm.entity.WmImNoticeIEntity;
import com.zzjee.wm.service.WmImNoticeHServiceI;
import com.zzjee.yongyoubase.openapi4j.exception.OpenAPIException;
import com.zzjee.yongyoubase.openapi4j.service.*;
import com.alibaba.fastjson.JSONArray;
import org.jeecgframework.core.util.DateUtils;
import org.jeecgframework.core.util.JSONHelper;
import org.jeecgframework.core.util.ResourceUtil;
import org.jeecgframework.core.util.StringUtil;
import org.apache.commons.lang.StringUtils;
import org.jeecgframework.core.util.*;
import org.jeecgframework.web.system.service.SystemService;
import org.springframework.util.DigestUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.nio.charset.Charset;
import java.util.*;
@ -21,137 +30,336 @@ public class yyUtil {
* Time: 2:07
*/
public static JSONObject getProduct(Map<String, Object> params) {
String to_account = params.get("to_account").toString(); //提供方id
// String page_index = args[1]; // 页号
// String rows_per_page = args[2]; // 每页行数
// String code_begin = args[3]; // 起始编码
// String code_end = args[4]; // 结束编码
// String name = args[5]; // 名称关键字
// String sort_code = args[6]; // 分类编码
// String sort_name = args[7]; //分类名称关键字
public static void getProduct() {
Map<String, String> paramMap = new HashMap<String, String>();
paramMap.put("to_account", to_account);
paramMap.put("page_index", "1");
paramMap.put("rows_per_page", "20000000");
// paramMap.put("code_begin", code_begin);
// paramMap.put("code_end", code_end);
// paramMap.put("name", name);
// paramMap.put("sort_code", sort_code);
// paramMap.put("sort_name", sort_name);
String dbKey= ResourceUtil.getConfigByName("yydbkey");
List<Map<String, Object>> result=null;
List<Map<String, Object>> resultdw=null;
List<Map<String, Object>> resultgt=null;
String querySql = "select * from Inventory";
Map queryparams = new LinkedHashMap<String,Object>();
SystemService systemService =ApplicationContextUtil.getContext().getBean(SystemService.class);
InventoryService ds = new InventoryService();
try {
JSONObject record = ds.batchGet(paramMap);
return record;
} catch (OpenAPIException e) {
return null;
if(StringUtils.isNotBlank(dbKey)) {
result = DynamicDBUtil.findList(dbKey, SqlUtil.jeecgCreatePageSql(dbKey, querySql, queryparams, 1, 1000000));
}
}
public static Map<String, Object> getPo(Map<String, Object> params) {
String to_account = params.get("to_account").toString(); //提供方id String page_index = args[1];// 页号
// String rows_per_page = args[2];// 每页行数
// String code_begin = args[3];// 起始订单编号
// String code_end = args[4];// 结束订单编号
// String state = args[5];// 订单状态
// String date_begin = args[6];// 起始订单日期,格式:yyyy-MM-dd
// String date_end = args[7];// 结束订单日期,格式:yyyy-MM-dd
//
// String vendorcode = args[8];// 供应商编码,可以通过 api/vendor 获取
// String vendorname = args[9];// 供应商名称关键字,可以通过 api/vendor 获取
// String personcode = args[10];// 业务员编码,可以通过 api/person 获取
// String personname = args[11];// 业务员名称关键字,可以通过 api/person 获取
// String deptcode = args[12];// 部门编码,可以通过 api/department 获取
// String deptname = args[13];// 部门名称关键字,可以通过 api/department 获取
// String remark = args[14];// 备注关键字
Map<String, String> paramMap = new HashMap<String, String>();
paramMap.put("to_account", to_account);
paramMap.put("page_index", "1");
paramMap.put("rows_per_page", "200000");
// paramMap.put("code_begin", code_begin);
// paramMap.put("code_end", code_end);
paramMap.put("date_begin", DateUtils.date2Str(DateUtils.date_sdf));
paramMap.put("date_end", DateUtils.date2Str(DateUtils.date_sdf));
// paramMap.put("state", state);
// paramMap.put("vendorcode", vendorcode);
// paramMap.put("vendorname", vendorname);
// paramMap.put("personcode", personcode);
// paramMap.put("personname", personname);
// paramMap.put("deptcode", deptcode);
// paramMap.put("deptname", deptname);
// paramMap.put("remark", remark);
PurchaseOrderService purchaseOrderService = new PurchaseOrderService();
Map<String, Object> resmap = new HashMap<String, Object>();
try {
JSONObject record = purchaseOrderService.batchGet(paramMap);
JSONArray jsonarray = JSONArray.parseArray(record.get("purchaseorderlist").toString());
for(int i=0;i<jsonarray.size();i++){
JSONObject jspo = jsonarray.getJSONObject(i); // 遍历 jsonarray 数组,把每一个对象转成 json 对象
String poid = jspo.get("code").toString();
try {
JSONObject recordone = purchaseOrderService.get(poid, to_account);
resmap.put(Integer.toString(i),recordone);
} catch (OpenAPIException e) {
e.printStackTrace();
}
}
return resmap;
} catch (OpenAPIException e) {
return null;
}
}
public static Map<String, Object> getSdvl(Map<String, Object> params) {
String to_account = params.get("to_account").toString(); //提供方id String page_index = args[1];// 页号
// String page_index = args[1];// 页号
// String rows_per_page = args[2];// 每页行数
// String code_begin = args[3];// 起始单据编号
// String code_end = args[4];// 结束单据编号
// String state = args[5];// 订单状态
// String date_begin = args[6];// 起始制单日期,格式:yyyy-MM-dd
// String date_end = args[7];// 结束制单日期,格式:yyyy-MM-dd
// String custcode = args[8];// 客户编码,可以通过 api/customer 获取
// String cusname = args[9];// 客户名称关键字,可以通过 api/customer 获取
// String personcode = args[10];// 业务员编码,可以通过 api/person 获取
// String personname = args[11];// 业务员名称关键字,可以通过 api/person 获取
// String deptcode = args[12];// 部门编码,可以通过 api/department 获取
// String deptname = args[13];// 部门名称关键字,可以通过 api/department 获取
// String remark = args[14];// 备注关键字
Map<String, String> paramMap = new HashMap<String, String>();
paramMap.put("to_account", to_account);
paramMap.put("page_index", "1");
paramMap.put("rows_per_page", "200000");
// paramMap.put("code_begin", code_begin);
// paramMap.put("code_end", code_end);
paramMap.put("date_begin", DateUtils.date2Str(DateUtils.date_sdf));
paramMap.put("date_end", DateUtils.date2Str(DateUtils.date_sdf));
// paramMap.put("state", state);
// paramMap.put("custcode", custcode);
// paramMap.put("cusname", cusname);
// paramMap.put("personcode", personcode);
// paramMap.put("personname", personname);
// paramMap.put("deptcode", deptcode);
// paramMap.put("deptname", deptname);
// paramMap.put("remark", remark);
ConsignmentService consignmentService = new ConsignmentService();
Map<String, Object> resmap = new HashMap<String, Object>();
try {
JSONObject record = consignmentService.batchGet(paramMap);
JSONArray jsonarray = JSONArray.parseArray(record.get("consignmentlist").toString());
for(int i=0;i<jsonarray.size();i++){
JSONObject sdpo = jsonarray.getJSONObject(i); // 遍历 jsonarray 数组,把每一个对象转成 json 对象
String sdid = sdpo.get("code").toString();
querySql = "select * from ComputationUnit";
if(StringUtils.isNotBlank(dbKey)) {
resultdw = DynamicDBUtil.findList(dbKey, SqlUtil.jeecgCreatePageSql(dbKey, querySql, queryparams, 1, 1000000));
}
querySql = "select * from InventoryClass";
if(StringUtils.isNotBlank(dbKey)) {
resultgt = DynamicDBUtil.findList(dbKey, SqlUtil.jeecgCreatePageSql(dbKey, querySql, queryparams, 1, 1000000));
}
if (resultgt!=null&&resultgt.size()>0) {
for (int i = 0; i < resultgt.size(); i++) {
Map<String, Object> prodbo = resultgt.get(i);
BaGoodsTypeEntity mdn = new BaGoodsTypeEntity();
mdn.setGoodsTypeCode(prodbo.get("cInvCCode").toString());
mdn.setGoodsTypeName(prodbo.get("cInvCName").toString());
try {
JSONObject recordone = consignmentService.get(sdid, to_account);
resmap.put(Integer.toString(i),recordone);
} catch (OpenAPIException e) {
e.printStackTrace();
BaGoodsTypeEntity bagoodsType = systemService.findUniqueByProperty(
BaGoodsTypeEntity.class, "goodsTypeCode", mdn.getGoodsTypeCode());
if(bagoodsType==null){
bagoodsType = new BaGoodsTypeEntity();
MyBeanUtils.copyBeanNotNull2Bean(mdn,bagoodsType);
systemService.save(bagoodsType);
}else{
MyBeanUtils.copyBeanNotNull2Bean(mdn,bagoodsType);
systemService.updateEntitie(bagoodsType);
}
}catch (Exception e){
}
}
}
if (resultdw!=null&&resultdw.size()>0) {
for (int i = 0; i < resultdw.size(); i++) {
Map<String, Object> prodbo = resultdw.get(i);
BaUnitEntity mdn = new BaUnitEntity();
mdn.setUnitCode(prodbo.get("cComunitCode").toString());
mdn.setUnitZhName(prodbo.get("cComUnitName").toString());
try {
BaUnitEntity baunit = systemService.findUniqueByProperty(
BaUnitEntity.class, "unitCode", mdn.getUnitCode());
if(baunit==null){
baunit = new BaUnitEntity();
MyBeanUtils.copyBeanNotNull2Bean(mdn,baunit);
systemService.save(baunit);
}else{
MyBeanUtils.copyBeanNotNull2Bean(mdn,baunit);
systemService.updateEntitie(baunit);
}
}catch (Exception e){
}
}
}
if (result!=null&&result.size()>0){
for(int i = 0;i<result.size();i++){
Map<String, Object> prodbo = result.get(i);
String ShpBianMa = prodbo.get("cInvCode").toString();
MdGoodsEntity mdn = new MdGoodsEntity();
mdn.setShpBianMa(ShpBianMa);
mdn.setChlShl("1");
mdn.setSuoShuKeHu("hwm");
mdn.setShpMingCheng(prodbo.get("cInvName").toString());
mdn.setBzhiQi("360");
mdn.setChpShuXing(prodbo.get("cInvCCode").toString());
// mdn.setChpShuXing("其他");
mdn.setJshDanWei(prodbo.get("cComUnitCode").toString());
BaUnitEntity baunit = systemService.findUniqueByProperty(
BaUnitEntity.class, "unitCode", mdn.getJshDanWei());
if (baunit !=null){
mdn.setJshDanWei(baunit.getUnitZhName());
mdn.setShlDanWei(baunit.getUnitZhName());
}
try {
mdn.setShpTiaoMa(prodbo.get("cBarCode").toString());
}catch (Exception e){
}
mdn.setCfWenCeng("低温");
mdn.setJiZhunwendu("1");
mdn.setTiJiCm("1");
mdn.setZhlKg("1");
mdn.setChlKongZhi("N");
mdn.setJfShpLei("10");
mdn.setMpCengGao("99");
mdn.setMpDanCeng("99");
try {
MdGoodsEntity mdGoods = systemService.findUniqueByProperty(
MdGoodsEntity.class, "shpBianMa", ShpBianMa);
if(mdGoods==null){
mdGoods = new MdGoodsEntity();
MyBeanUtils.copyBeanNotNull2Bean(mdn,mdGoods);
systemService.save(mdGoods);
}else{
MyBeanUtils.copyBeanNotNull2Bean(mdn,mdGoods);
systemService.updateEntitie(mdGoods);
}
}catch (Exception e){
}
}
}
}
public static void getPo(String indate) {
// PO_Pomain 采购订单主表
// PO_Podetails 采购订单子表
String dbKey= ResourceUtil.getConfigByName("yydbkey");
List<Map<String, Object>> result=null;
List<Map<String, Object>> resultdetail=null;
String querySql = "select * from PO_Pomain where dpodate = '"+indate+"'";
Map queryparams = new LinkedHashMap<String,Object>();
SystemService systemService =ApplicationContextUtil.getContext().getBean(SystemService.class);
WmImNoticeHServiceI wmImNoticeHService =ApplicationContextUtil.getContext().getBean(WmImNoticeHServiceI.class);
if(StringUtils.isNotBlank(dbKey)) {
result = DynamicDBUtil.findList(dbKey, SqlUtil.jeecgCreatePageSql(dbKey, querySql, queryparams, 1, 1000000));
}
if (result!=null&&result.size()>0) {
for (int i = 0; i < result.size(); i++) {
Map<String, Object> prodbo = result.get(i);
String poid = prodbo.get("poid").toString();
if (StringUtil.isNotEmpty(poid)) {
WmImNoticeHEntity wmimh = systemService.findUniqueByProperty(WmImNoticeHEntity.class, "imCusCode", poid);
if (wmimh == null) {
WmImNoticeHEntity wmImNoticeH = new WmImNoticeHEntity();
List<WmImNoticeIEntity> wmImNoticeIListnew = new ArrayList<WmImNoticeIEntity>();
wmImNoticeH.setOrderTypeCode("01");
String noticeid = yyUtil.getNextNoticeid(wmImNoticeH.getOrderTypeCode());
wmImNoticeH.setCusCode(ResourceUtil.getConfigByName("yy.cuscode"));
wmImNoticeH.setNoticeId(noticeid);
// wmImNoticeH.setPlatformCode(Integer.toString(billResult.getData().get(s).getPiId()));
// wmImNoticeH.setPiClass(billResult.getData().get(s).getPiClass());
// wmImNoticeH.setPiMaster(master);
// wmImNoticeH.setSupCode(billResult.getData().get(s).getPiCardcode());
// MdSupEntity mdsup = systemService.findUniqueByProperty(MdSupEntity.class, "gysBianMa", wmImNoticeH.getSupCode());
// if (mdsup != null) {
// wmImNoticeH.setSupName(mdsup.getZhongWenQch());
// }
try{
wmImNoticeH.setImBeizhu(prodbo.get("cMemo").toString());
}catch (Exception e){
}
wmImNoticeH.setImCusCode(poid);
String querySqldetail = "select * from PO_Podetails where poid = '"+poid+"'";
if (resultdetail!=null){
resultdetail.clear();
}
resultdetail = DynamicDBUtil.findList(dbKey, SqlUtil.jeecgCreatePageSql(dbKey, querySqldetail, queryparams, 1, 1000000));
for (int k = 0; k < resultdetail.size(); k++) {
WmImNoticeIEntity wmi = new WmImNoticeIEntity();
Map<String, Object> proddet = resultdetail.get(k);
wmi.setGoodsCode(proddet.get("cInvCode").toString());
MvGoodsEntity mvgoods = systemService.findUniqueByProperty(
MvGoodsEntity.class, "goodsCode", wmi.getGoodsCode());
if (mvgoods != null) {
wmi.setGoodsName(mvgoods.getGoodsName());
wmi.setGoodsUnit(mvgoods.getShlDanWei());
}
wmi.setGoodsCount(Double.toString(new BigDecimal(proddet.get("iQuantity").toString()).setScale(2, RoundingMode.UP).doubleValue()));
// wmi.setGoodsPrdData(billResult.getData().get(s).getDetail().get(k).getPdProdmadedate2User());
// wmi.setOtherId();
wmImNoticeIListnew.add(wmi);
}
wmImNoticeHService.addMain(wmImNoticeH, wmImNoticeIListnew);
}
} else {
continue;
}
}
}
}
private static String getNextNoticeid(String orderType){
String noticeid=null;
SystemService systemService =ApplicationContextUtil.getContext().getBean(SystemService.class);
Map<String, Object> countMap = systemService
.findOneForJdbc("SELECT count(*)+1 as count FROM wm_im_notice_h t where TO_DAYS(t.create_date) = TO_DAYS(NOW());");
if (StringUtil.isEmpty(orderType)){
orderType = "01";
}
if (countMap != null) {
if(orderType.equals("03")){
noticeid = "TH"
+ DateUtils.date2Str(new Date(), DateUtils.yyyyMMdd)
+ "-"
+ StringUtil.leftPad(
((Long) countMap.get("count")).intValue(), 4,
'0');
}else if(orderType.equals("01")){
noticeid = "RK"
+ DateUtils.date2Str(new Date(), DateUtils.yyyyMMdd)
+ "-"
+ StringUtil.leftPad(
((Long) countMap.get("count")).intValue(), 4,
'0');
}else if(orderType.equals("04")){
noticeid = "YK"
+ DateUtils.date2Str(new Date(), DateUtils.yyyyMMdd)
+ "-"
+ StringUtil.leftPad(
((Long) countMap.get("count")).intValue(), 4,
'0');
}else if(orderType.equals("09")){
noticeid = "QT"
+ DateUtils.date2Str(new Date(), DateUtils.yyyyMMdd)
+ "-"
+ StringUtil.leftPad(
((Long) countMap.get("count")).intValue(), 4,
'0');
}
}
return noticeid;
}
private static String getNextomNoticeId(String orderType){
SystemService systemService =ApplicationContextUtil.getContext().getBean(SystemService.class);
Map<String, Object> countMap = systemService
.findOneForJdbc("SELECT count(*)+1 as count FROM wm_om_notice_h t where TO_DAYS(t.create_date) = TO_DAYS(NOW());");
String noticeid = null;
if (StringUtil.isEmpty(orderType)){
orderType = "11";
}
if(orderType.equals("19")){
noticeid = "QT"
+ DateUtils.date2Str(new Date(), DateUtils.yyyyMMdd)
+ "-"
+ StringUtil.leftPad(
((Long) countMap.get("count")).intValue(), 4,
'0');
}else {
noticeid = "CK"
+ DateUtils.date2Str(new Date(), DateUtils.yyyyMMdd)
+ "-"
+ StringUtil.leftPad(
((Long) countMap.get("count")).intValue(), 4,
'0');
}
return noticeid;
}
public static void getSdvl(String indate) {
// / PO_Pomain 采购订单主表
// PO_Podetails 采购订单子表
String dbKey= ResourceUtil.getConfigByName("yydbkey");
List<Map<String, Object>> result=null;
List<Map<String, Object>> resultdetail=null;
String querySql = "select * from PO_Pomain where dpodate = '"+indate+"'";
Map queryparams = new LinkedHashMap<String,Object>();
SystemService systemService =ApplicationContextUtil.getContext().getBean(SystemService.class);
WmImNoticeHServiceI wmImNoticeHService =ApplicationContextUtil.getContext().getBean(WmImNoticeHServiceI.class);
if(StringUtils.isNotBlank(dbKey)) {
result = DynamicDBUtil.findList(dbKey, SqlUtil.jeecgCreatePageSql(dbKey, querySql, queryparams, 1, 1000000));
}
if (result!=null&&result.size()>0) {
for (int i = 0; i < result.size(); i++) {
Map<String, Object> prodbo = result.get(i);
String poid = prodbo.get("poid").toString();
if (StringUtil.isNotEmpty(poid)) {
WmImNoticeHEntity wmimh = systemService.findUniqueByProperty(WmImNoticeHEntity.class, "imCusCode", poid);
if (wmimh == null) {
WmImNoticeHEntity wmImNoticeH = new WmImNoticeHEntity();
List<WmImNoticeIEntity> wmImNoticeIListnew = new ArrayList<WmImNoticeIEntity>();
wmImNoticeH.setOrderTypeCode("01");
String noticeid = yyUtil.getNextNoticeid(wmImNoticeH.getOrderTypeCode());
wmImNoticeH.setCusCode(ResourceUtil.getConfigByName("yy.cuscode"));
wmImNoticeH.setNoticeId(noticeid);
// wmImNoticeH.setPlatformCode(Integer.toString(billResult.getData().get(s).getPiId()));
// wmImNoticeH.setPiClass(billResult.getData().get(s).getPiClass());
// wmImNoticeH.setPiMaster(master);
// wmImNoticeH.setSupCode(billResult.getData().get(s).getPiCardcode());
// MdSupEntity mdsup = systemService.findUniqueByProperty(MdSupEntity.class, "gysBianMa", wmImNoticeH.getSupCode());
// if (mdsup != null) {
// wmImNoticeH.setSupName(mdsup.getZhongWenQch());
// }
wmImNoticeH.setImCusCode(poid);
String querySqldetail = "select * from PO_Podetails where poid = '"+poid+"'";
resultdetail = DynamicDBUtil.findList(dbKey, SqlUtil.jeecgCreatePageSql(dbKey, querySqldetail, queryparams, 1, 1000000));
for (int k = 0; k < resultdetail.size(); k++) {
WmImNoticeIEntity wmi = new WmImNoticeIEntity();
Map<String, Object> proddet = result.get(i);
wmi.setGoodsCode(proddet.get("cInvCode").toString());
MvGoodsEntity mvgoods = systemService.findUniqueByProperty(
MvGoodsEntity.class, "goodsCode", wmi.getGoodsCode());
if (mvgoods != null) {
wmi.setGoodsName(mvgoods.getGoodsName());
wmi.setGoodsUnit(mvgoods.getShlDanWei());
}
wmi.setGoodsCount(proddet.get("iQuantity").toString());
// wmi.setGoodsPrdData(billResult.getData().get(s).getDetail().get(k).getPdProdmadedate2User());
// wmi.setOtherId();
wmImNoticeIListnew.add(wmi);
}
wmImNoticeHService.addMain(wmImNoticeH, wmImNoticeIListnew);
}
} else {
continue;
}
}
return resmap;
} catch (OpenAPIException e) {
return null;
}
}