| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831 |
- package cn.com.lzt.ordersfixasset.controller;
- import cn.com.lzt.arrangeduty.dao.UserOrgMinidao;
- import cn.com.lzt.arrangeduty.dto.UserOrgDto;
- import cn.com.lzt.common.controller.BaseLztController;
- import cn.com.lzt.common.util.DictUtil;
- import cn.com.lzt.common.util.LztUtil;
- import cn.com.lzt.common.util.UserUtil;
- import cn.com.lzt.common.view.JsonDataModelAndView;
- import cn.com.lzt.goodscategory.entity.TBGoodsCategoryEntity;
- import cn.com.lzt.goodsinfo.entity.TBGoodsInfoEntity;
- import cn.com.lzt.logistics.entity.TBLogisticsEntity;
- import cn.com.lzt.orders.entity.OrderMonthsEntity;
- import cn.com.lzt.orders.entity.OrdersFlowDto;
- import cn.com.lzt.ordersfixasset.dao.OrdersFixAssetDao;
- import cn.com.lzt.ordersfixasset.entity.OrderFixAssetProductsEntity;
- import cn.com.lzt.ordersfixasset.entity.OrdersFixAssetEntity;
- import cn.com.lzt.ordersfixasset.page.OrdersFixAssetPage;
- import cn.com.lzt.ordersfixasset.service.OrdersFixAssetServiceI;
- import cn.com.lzt.priceinfo.entity.TBPriceInfoEntity;
- import cn.com.lzt.relatedunits.entity.RelatedUnitsEntity;
- import cn.com.lzt.relatedunits.service.RelatedUnitsServiceI;
- import cn.com.lzt.tools.OrderNumTools;
- import cn.com.lzt.tools.SCMConsole;
- import cn.com.lzt.useractiviti.data.dao.UseractivitiDataDao;
- import cn.com.lzt.useractiviti.data.util.ActivitiPdfExport;
- import cn.com.lzt.useractiviti.data.util.ActivitiTools;
- import cn.com.lzt.warehouse.entity.WarehouseEntity;
- import com.lowagie.text.pdf.PdfPTable;
- import com.jeecg.qianbao.util.FormProcUtil;
- import com.xcgl.utils.XcglDateUtils;
- import com.xcgl.weixin.entity.WXAjaxJson;
- import com.xcgl.weixin.service.WXServiceI;
- import org.activiti.engine.HistoryService;
- import org.activiti.engine.RepositoryService;
- import org.activiti.engine.RuntimeService;
- import org.activiti.engine.TaskService;
- import org.activiti.engine.impl.RepositoryServiceImpl;
- import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
- import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
- import org.activiti.engine.impl.pvm.PvmTransition;
- import org.activiti.engine.impl.pvm.process.ActivityImpl;
- import org.activiti.engine.task.Task;
- import org.apache.commons.lang.CommonRandomUtil;
- import org.apache.commons.lang.xwork.StringUtils;
- import org.apache.log4j.Logger;
- import org.jeecgframework.core.beanvalidator.BeanValidators;
- import org.jeecgframework.core.common.dao.ICommonDao;
- import org.jeecgframework.core.common.exception.BusinessException;
- import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery;
- 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.extend.hqlsearch.HqlGenerateUtil;
- import org.jeecgframework.core.util.*;
- 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.vo.NormalExcelConstants;
- import org.jeecgframework.tag.core.easyui.TagUtil;
- import org.jeecgframework.tag.vo.datatable.SortDirection;
- import org.jeecgframework.web.system.dao.JeecgDictDao;
- import org.jeecgframework.web.system.pojo.base.DictEntity;
- import org.jeecgframework.web.system.pojo.base.TSBaseUser;
- import org.jeecgframework.web.system.pojo.base.TSDepart;
- import org.jeecgframework.web.system.pojo.base.TSUser;
- import org.jeecgframework.web.system.service.SystemService;
- import org.jeecgframework.web.system.service.UserService;
- import org.jeecgframework.workflow.common.WorkFlowGlobals;
- import org.jeecgframework.workflow.dto.DealOptionDto;
- import org.jeecgframework.workflow.model.activiti.ProcessHandle;
- import org.jeecgframework.workflow.model.activiti.Variable;
- import org.jeecgframework.workflow.pojo.activiti.ActRuTask;
- import org.jeecgframework.workflow.pojo.activiti.ActRuVariable;
- import org.jeecgframework.workflow.pojo.base.TPBpmLog;
- import org.jeecgframework.workflow.pojo.base.TSBaseBusQuery;
- import org.jeecgframework.workflow.service.ActivitiService;
- import org.jeecgframework.workflow.service.impl.TaskJeecgService;
- import org.jeecgframework.workflow.user.entity.TPTaskCcEntity;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.http.HttpHeaders;
- import org.springframework.http.HttpStatus;
- import org.springframework.http.MediaType;
- import org.springframework.http.ResponseEntity;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.ModelMap;
- import org.springframework.web.bind.annotation.*;
- import org.springframework.web.multipart.MultipartFile;
- import org.springframework.web.multipart.MultipartHttpServletRequest;
- import org.springframework.web.servlet.ModelAndView;
- import org.springframework.web.util.UriComponentsBuilder;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import javax.servlet.http.HttpSession;
- import javax.validation.ConstraintViolation;
- import javax.validation.Validator;
- import java.io.IOException;
- import java.math.BigDecimal;
- import java.net.URI;
- import java.text.DateFormat;
- import java.text.SimpleDateFormat;
- import java.util.*;
- //import cn.com.lzt.weixin.service.WXServiceI;
- /**
- * @Title: Controller
- * @Description: 订单表
- * @author onlineGenerator
- * @date 2017-06-07 17:15:24
- * @version V1.0
- *
- */
- @Controller
- @RequestMapping("/ordersFixAssetController")
- public class OrdersFixAssetController extends BaseLztController {
- /**
- * Logger for this class
- */
- private static final Logger logger = Logger.getLogger(OrdersFixAssetController.class);
- @Autowired
- private OrdersFixAssetServiceI ordersFixAssetService;
- @Autowired
- private SystemService systemService;
- @Autowired
- private Validator validator;
- @Autowired
- public ICommonDao commonDao = null;
- // @Autowired
- // private PaymentMiddleServiceI paymentMiddleService;
- @Autowired
- private RelatedUnitsServiceI relatedUnitsService;
- // @Autowired
- // private CollectMiddleServiceI collectMiddleService;
- @Autowired
- private OrdersFixAssetDao ordersFixAssetDao;
- @Autowired
- private JeecgDictDao jeecgDictDao;
- @Autowired
- private UserOrgMinidao userOrgdao;
- @Autowired
- private ActivitiService activitiService;
- @Autowired
- private TaskJeecgService taskJeecgService;
- @Autowired
- private TaskService taskService;
- @Autowired
- private RuntimeService runtimeService;
- @Autowired
- protected HistoryService historyService;
- @Autowired
- protected RepositoryService repositoryService;
- @Autowired
- protected WXServiceI wxservice;
- @Autowired
- protected UseractivitiDataDao useractivitiDataDao;
- @Autowired
- protected UserService userService;
- /**
- * 订单表列表 页面跳转
- *
- * @return
- */
- @RequestMapping(params = "list")
- public ModelAndView list(HttpServletRequest request) {
- return new ModelAndView("cn/com/lzt/orders/ordersList");
- }
- /**
- * 订单表列表 页面跳转
- *
- * @return
- */
- @RequestMapping(params = "listByWarehouse")
- public ModelAndView listByWarehouse(HttpServletRequest request) {
- // 当前登录用户ID
- TSUser tsuser = ResourceUtil.getSessionUser();
- String userid = tsuser.getId();
- String orderFor = request.getParameter("orderFor");
- boolean isProjectUser = UserUtil.isProjectUser(userid);
- request.setAttribute("isProjectUser", isProjectUser);
- if(isProjectUser) {
- String hql1 = "from WarehouseEntity where responsiblePerson=? and deleteFlag=0";
- List<WarehouseEntity> warehouseList = systemService.findHql(hql1, userid);
- request.setAttribute("userid", userid);
- if (warehouseList.size() > 1)
- request.setAttribute("isMultiWarehouse", "1");
- else if(warehouseList.size()==1){
- request.setAttribute("isMultiWarehouse", "0");
- request.setAttribute("warehouseid", warehouseList.get(0).getId());
- }else {
- request.setAttribute("isMultiWarehouse", "0");
- }
- }
- String role = userService.getUserRole(tsuser);
- request.setAttribute("fjl",StringUtils.contains(role, Globals.POSITION_TYPE_XZBFJL));
- request.setAttribute("createByUserName",tsuser.getUserName());
- ModelAndView mv = new ModelAndView("cn/com/lzt/ordersfixasset/ordersListByWarehouse");
- if(StringUtils.isNotEmpty(orderFor) && orderFor.equals("1")) {
- //自行申购签报
- mv = new ModelAndView("cn/com/lzt/ordersfixasset/ordersListByWarehouse-own");
- request.setAttribute("orderFor", orderFor);
- }else {
- //固定物料申购(办公室)
- request.setAttribute("orderFor", "0");
- }
- return mv;
- }
- /**
- * 请购单审批页面
- *
- * @return
- */
- @RequestMapping(params = "ordersList_task")
- public ModelAndView list_orderstask(HttpServletRequest request) {
- return new ModelAndView("cn/com/lzt/ordersfixasset/ordersList_task");
- }
- /**
- * 请购单审批页面加载
- *
- * @return
- */
- @RequestMapping(params = "datagrid_orderstask")
- public void datagrid_orderstask(OrdersFixAssetEntity orders,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
- CriteriaQuery cq = new CriteriaQuery(OrdersFixAssetEntity.class, dataGrid);
- String orderDateBegin = request.getParameter("orderDate_begin");
- String orderDateEnd = request.getParameter("orderDate_end");
- String orderOnumber = orders.getOrderOnumber();
- if(StringUtils.isNotBlank(orderOnumber)){
- orders.setOrderOnumber("*" +orderOnumber +"*");
- }
- cq.addOrder("createDate", SortDirection.desc);
- //查询条件组装器
- HqlGenerateUtil.installHql(cq, orders);
- try{
- //自定义追加查询条件
- if(StringUtils.isNotBlank(orderDateBegin) && StringUtils.isNotBlank(orderDateEnd)){
- cq.ge("createDate", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(orderDateBegin + " 00:00:00"));
- cq.le("createDate", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(orderDateEnd + " 23:59:59"));
- }
- }catch (Exception e) {
- throw new BusinessException(e.getMessage());
- }
- cq.notEq("bpmStatus", "1");
- cq.add();
- List<OrdersFixAssetEntity> list = ordersFixAssetService.getListByCriteriaQuery(cq, false);
- if(list == null || list.size()==0) {
- return;
- }
- List<OrdersFixAssetEntity> result = new ArrayList<OrdersFixAssetEntity>();
- HashMap<String, OrdersFixAssetEntity> hm_id2obj = new HashMap<>();
- for(OrdersFixAssetEntity oe : list) {
- hm_id2obj.put(oe.getId(), oe);
- }
- TSUser user = ResourceUtil.getSessionUser();
- List taskList = this.activitiService.findPriTodoTasks(user.getUserName(), request);
- for(int i=0 ; i<taskList.size() ; i++) {
- TSBaseBusQuery busobj = (TSBaseBusQuery)taskList.get(i);
- String id = activitiService.getBusinessKeyByTask(busobj.getProcess().getTask().getId());
- OrdersFixAssetEntity order = hm_id2obj.get(id);
- if(order != null) {
- result.add(order);
- order.setProcessObject(busobj);
- }
- }
- dataGrid.setResults(result);
- dataGrid.setFooter("totalMoney,baojieSum,gongchengSum,bangongSum");
- TagUtil.datagrid(response, dataGrid);
- }
- @RequestMapping(params = {"popDealOption"})
- public ModelAndView popDealOption(DealOptionDto dto, HttpServletRequest request) {
- request.setAttribute("dealParam", dto);
- return new ModelAndView("cn/com/lzt/ordersfixasset/dealOrderFlowWriteOption");
- }
- public Task getTask(String taskId) {
- return (Task)this.taskService.createTaskQuery().taskId(taskId).singleResult();
- }
- /**
- * 获取任务下一步节点的id
- * @param taskId
- * @param transName 通过或者驳回
- * @return
- */
- private String getTaskNextNodeId(String taskId, String transName) {
- List outTransitions = null;
- ArrayList trans = new ArrayList();
- Task task = this.getTask(taskId);
- ProcessDefinitionEntity def = (ProcessDefinitionEntity)((RepositoryServiceImpl)this.repositoryService).getDeployedProcessDefinition(task.getProcessDefinitionId());
- List activitiList = def.getActivities();
- String excId = task.getExecutionId();
- ExecutionEntity execution = (ExecutionEntity)this.runtimeService.createExecutionQuery().executionId(excId).singleResult();
- String activitiId = execution.getActivityId();
- Iterator arg10 = activitiList.iterator();
- while(arg10.hasNext()) {
- ActivityImpl activityImpl = (ActivityImpl)arg10.next();
- String id = activityImpl.getId();
- if(activitiId.equals(id)) {
- outTransitions = activityImpl.getOutgoingTransitions();
- Iterator arg13 = outTransitions.iterator();
- while(arg13.hasNext()) {
- PvmTransition tr = (PvmTransition)arg13.next();
- if(tr.getId() != null) {
- String name = (String)(oConvertUtils.isNotEmpty(tr.getProperty("name"))?tr.getProperty("name"):tr.getId());
- if(transName.equals(name)) {
- return tr.getDestination().getId();
- }
- }
- }
- return null;
- }
- }
- return null;
- }
- private List<OrdersFlowDto> getWorkflowParam(HttpServletRequest request){
- List<OrdersFlowDto> result = new ArrayList<>();
- String taskIdsInReq = oConvertUtils.getString(request.getParameter("taskId"));
- String dealOption = oConvertUtils.getString(request.getParameter("dealOption"));
- String transName = oConvertUtils.getString(request.getParameter("nextNodeName"));
- if("agree".equals(transName)) {
- transName = "通过";
- }else {
- transName = "驳回";
- }
- if(StringUtils.isEmpty(taskIdsInReq)) {
- return result;
- }
- String[] taskids = taskIdsInReq.split(",");
- for(int i=0 ; i<taskids.length ; i++) {
- String nextNode = getTaskNextNodeId(taskids[i],transName);
- OrdersFlowDto dto = new OrdersFlowDto();
- dto.setDealOption(dealOption);
- dto.setModel("1");
- dto.setNextnode(nextNode);
- dto.setTaskId(taskids[i]);
- dto.setOperateType(transName);
- result.add(dto);
- }
- return result;
- }
- /**
- * 批量审批
- * @param request
- * @param var
- * @return
- * @throws Exception
- */
- @RequestMapping(params = {"processComplete"})
- @ResponseBody
- public AjaxJson processComplete(HttpServletRequest request, Variable var) throws Exception {
- List<OrdersFlowDto> dtos = getWorkflowParam(request);
- AjaxJson j = new AjaxJson();
- String nextUser = oConvertUtils.getString(request.getParameter("id"));
- try {
- for(OrdersFlowDto dto : dtos) {
- ProcessHandle processHandle = this.activitiService.getProcessHandle(dto.getTaskId());
- if(oConvertUtils.isEmpty(processHandle)) {
- j.setSuccess(false);
- j.setMsg(MutiLangUtil.getMutiLangInstance().getLang("process.task.notexist"));
- return j;
- } else {
- Map map = var.getVariableMap(processHandle.getTpProcesspros());
- Task task = this.activitiService.getTask(dto.getTaskId());
- String processInstanceId = task.getProcessInstanceId();
- String ccUserNames="";
- if("1".equals(dto.getModel())) {
- if("end".equals(dto.getNextnode())) {
- this.taskJeecgService.goProcessTaskNode(dto.getTaskId(), dto.getNextnode(), map);
- } else {
- this.taskJeecgService.goProcessTaskNode(dto.getTaskId(), dto.getNextnode(), map);
- ccUserNames = this.taskJeecgService.getTaskIdByProins(processInstanceId, dto.getNextnode());
- }
- }
- //ccUserNames = oConvertUtils.getString(request.getParameter("ccUserNames"));
- this.taskCc(ccUserNames, task);
- TPBpmLog arg30 = new TPBpmLog();
- TSUser arg31 = ResourceUtil.getSessionUser();
- arg30.setBpm_id(task.getProcessInstanceId());
- arg30.setTask_name(processHandle.getTpProcess().getProcessname());
- arg30.setTask_node(processHandle.getTpProcessnode().getProcessnodename());
- arg30.setOp_code(arg31.getUserKey());
- arg30.setOp_name(arg31.getRealName());
- arg30.setOp_time(DataUtils.gettimestamp());
- // arg30.setLinename(nextNodeName);
- arg30.setTaskId(dto.getTaskId());
- arg30.setMemo(dto.getDealOption());
- String tableName = null;
- String busId = null;
- boolean hastep_name = false;
- String curttentstep = null;
- List actRuVariables = this.systemService.findByProperty(ActRuVariable.class, "actRuExecutionByProcInstId.id", processInstanceId);
- for(int list = 0; list < actRuVariables.size(); ++list) {
- ActRuVariable item = (ActRuVariable)actRuVariables.get(list);
- if(WorkFlowGlobals.BPM_FORM_KEY.equals(item.getName())) {
- tableName = item.getText();
- }
- if(WorkFlowGlobals.BPM_DATA_ID.equals(item.getName())) {
- busId = item.getText();
- }
- if("step_name".equals(item.getName())) {
- hastep_name = true;
- }
- }
- List arg32 = this.systemService.findByProperty(ActRuTask.class, "actRuExecutionByProcInstId.id", processInstanceId);
- if(oConvertUtils.isNotEmpty(arg32) && arg32.size() > 0) {
- curttentstep = ((ActRuTask)arg32.get(0)).getName();
- }
- if(hastep_name) {
- this.activitiService.updateBusStepname(tableName, busId, curttentstep);
- }
- if("end".equals(dto.getNextnode())) {
- this.activitiService.updateBusStepname(tableName, busId, MutiLangUtil.getMutiLangInstance().getLang("process.complete"));
- }
- this.systemService.save(arg30);
- }
- }
- j.setMsg("审批成功!");
- j.setObj(dtos);
- } catch (BusinessException arg28) {
- j.setSuccess(false);
- j.setMsg(MutiLangUtil.getMutiLangInstance().getLang("process.do.fail") + ":" + MutiLangUtil.getMutiLangInstance().getLang("process.nextnode.unknownerror"));
- arg28.printStackTrace();
- } catch (Exception arg29) {
- j.setSuccess(false);
- j.setMsg(MutiLangUtil.getMutiLangInstance().getLang("process.do.fail") + ":" + MutiLangUtil.getMutiLangInstance().getLang("nextnode.nopersion.error"));
- arg29.printStackTrace();
- }
- return j;
- }
- private void taskCc(String ccUserNames, Task task) {
- if(!CommonRandomUtil.isEmpty(ccUserNames)) {
- TSUser user = ResourceUtil.getSessionUser();
- String[] ccUserNameArr = ccUserNames.split(",");
- TPTaskCcEntity taskCcEntity = null;
- String[] arg8 = ccUserNameArr;
- int arg7 = ccUserNameArr.length;
- for(int arg6 = 0; arg6 < arg7; ++arg6) {
- String ccUserName = arg8[arg6];
- taskCcEntity = new TPTaskCcEntity();
- taskCcEntity.setProcDefId(task.getProcessDefinitionId());
- taskCcEntity.setProcInstId(task.getProcessInstanceId());
- taskCcEntity.setExecutionId(task.getExecutionId());
- taskCcEntity.setTaskDefKey(task.getTaskDefinitionKey());
- taskCcEntity.setTaskId(task.getId());
- taskCcEntity.setTaskName(task.getName());
- taskCcEntity.setFromUserName(user.getUserName());
- taskCcEntity.setCcUserName(ccUserName);
- this.systemService.save(taskCcEntity);
- }
- }
- }
- /**
- * easyui AJAX请求数据
- *
- * @param request
- * @param response
- * @param dataGrid
- */
- @RequestMapping(params = "datagrid")
- public void datagrid(OrdersFixAssetEntity orders,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
- CriteriaQuery cq = new CriteriaQuery(OrdersFixAssetEntity.class, dataGrid);
- String orderDateBegin = request.getParameter("orderDate_begin");
- String orderDateEnd = request.getParameter("orderDate_end");
- String orderOnumber = orders.getOrderOnumber();
- if(StringUtils.isNotBlank(orderOnumber)){
- orders.setOrderOnumber("*" +orderOnumber +"*");
- }
- String warehouseName = orders.getWarehouseName();
- if(StringUtils.isNotBlank(warehouseName)){
- orders.setWarehouseName("*" +warehouseName +"*");
- }
- cq.addOrder("createDate", SortDirection.desc);
- //查询条件组装器
- HqlGenerateUtil.installHql(cq, orders);
- try{
- //自定义追加查询条件
- if(StringUtils.isNotBlank(orderDateBegin) && StringUtils.isNotBlank(orderDateEnd)){
- cq.ge("createDate", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(orderDateBegin + " 00:00:00"));
- cq.le("createDate", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(orderDateEnd + " 23:59:59"));
- }
- }catch (Exception e) {
- throw new BusinessException(e.getMessage());
- }
- cq.notEq("bpmStatus", "1");
- cq.add();
- List<OrdersFixAssetEntity> list = ordersFixAssetService.getListByCriteriaQuery(cq, false);
- dataGrid.setResults(list);
- // this.ordersFixAssetService.getDataGridReturn(cq, false);
- dataGrid.setFooter("totalMoney,baojieSum,gongchengSum,bangongSum");
- TagUtil.datagrid(response, dataGrid);
- }
- /**
- * easyui AJAX请求数据
- *
- * @param request
- * @param response
- * @param dataGrid
- */
- @RequestMapping(params = "datagridByWarehouse")
- public void datagridByWarehouse(OrdersFixAssetEntity orders,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
- CriteriaQuery cq = new CriteriaQuery(OrdersFixAssetEntity.class, dataGrid);
- String orderDateBegin = request.getParameter("orderDate_begin");
- String orderDateEnd = request.getParameter("orderDate_end");
- String orderOnumber = orders.getOrderOnumber();
- if(StringUtils.isNotBlank(orderOnumber)){
- orders.setOrderOnumber("*" +orderOnumber +"*");
- }
- cq.addOrder("createDate", SortDirection.desc);
- TSUser user = ResourceUtil.getSessionUser();
- String role = userService.getUserRole(user);
- if(!StringUtils.contains(role, Globals.POSITION_TYPE_XZBFJL)){
- orders.setCreateBy(user.getUserName());
- }
- //查询条件组装器
- HqlGenerateUtil.installHql(cq, orders);
- try{
- //自定义追加查询条件
- if(StringUtils.isNotBlank(orderDateBegin) && StringUtils.isNotBlank(orderDateEnd)){
- cq.ge("createDate", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(orderDateBegin + " 00:00:00"));
- cq.le("createDate", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(orderDateEnd + " 23:59:59"));
- }
- }catch (Exception e) {
- throw new BusinessException(e.getMessage());
- }
- cq.add();
- ordersFixAssetService.getDataGridReturn(cq, true);
- TagUtil.datagrid(response, dataGrid);
- }
- protected List<String> getUserWarehouse(){
- TSUser tuser = ResourceUtil.getSessionUser();
- UserOrgDto userOrgDto = new UserOrgDto();
- userOrgDto.setUserId(tuser.getId());
- List<UserOrgDto> dtos = userOrgdao.getUserOrgDtoByUserId(userOrgDto , null);
- StringBuffer sb = new StringBuffer();
- String sql = "select id from t_b_warehouse where responsible_person = '"+tuser.getId()+"'";
- if(dtos != null && dtos.size()>0) {
- for(int i=0 ; i<dtos.size() ; i++) {
- if(i>0) {
- sb.append(",");
- }
- sb.append("'");
- sb.append(dtos.get(i).getOrgId());
- sb.append("'");
- }
- sql += " or project_id in("+sb.toString()+")";
- }
- List<String> tsDList = systemService.findListbySql(sql);
- boolean isProjectUser = UserUtil.isProjectUser(tuser.getId());
- if(!isProjectUser) {//职能部门能看见总仓
- tsDList.add("ff808081665bfece0166a8ebaa7f2738");
- }
- return tsDList;
- }
- /**
- * 删除订单表
- *
- * @return
- */
- @RequestMapping(params = "doDel")
- @ResponseBody
- public AjaxJson doDel(OrdersFixAssetEntity orders, HttpServletRequest request) {
- AjaxJson j = new AjaxJson();
- orders = systemService.getEntity(OrdersFixAssetEntity.class, orders.getId());
- String message = "订单表删除成功";
- try{
- ordersFixAssetService.delMain(orders);
- 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){
- AjaxJson j = new AjaxJson();
- String message = "订单表删除成功";
- try{
- for(String id:ids.split(",")){
- OrdersFixAssetEntity orders = systemService.getEntity(OrdersFixAssetEntity.class,
- id
- );
- ordersFixAssetService.delMain(orders);
- 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 = "doAdd")
- @ResponseBody
- public AjaxJson doAdd(OrdersFixAssetEntity orders,OrdersFixAssetPage ordersPage, HttpServletRequest request) {
- if(StringUtils.isNotBlank(orders.getId())){
- return doUpdate(orders,ordersPage,request);
- }
- List<OrderFixAssetProductsEntity> orderProductsList = ordersPage.getOrderProductsList();
- AjaxJson j = new AjaxJson();
- String message = "添加成功";
- try{
- String warehouseid = orders.getWarehouseId();
- HttpSession session = ContextHolderUtils.getSession();
- TSUser tuser = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
- WarehouseEntity wh = systemService.get(WarehouseEntity.class, warehouseid);
- orders.setWarehouseName(wh.getWarehouseName());
- orders.setHandlerPersonId(tuser.getId());
- orders.setHandlerPersonName(tuser.getRealName());
- orders.setOrderOnumber(OrderNumTools.generate18OrderNum());// 采购单好
- orders.setOrderStatus(Globals.UNAPPROVED);// 未审批状态
- ordersFixAssetService.addMain(orders, orderProductsList);
- 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;
- }
- /**
- * 更新订单表
- *
- * @return
- */
- @RequestMapping(params = "doUpdate")
- @ResponseBody
- public AjaxJson doUpdate(OrdersFixAssetEntity orders, OrdersFixAssetPage ordersPage, HttpServletRequest request) {
- List<OrderFixAssetProductsEntity> orderProductsList = ordersPage.getOrderProductsList();
- AjaxJson j = new AjaxJson();
- String message = "更新成功";
- try{
- String warehouseid = orders.getWarehouseId();
- HttpSession session = ContextHolderUtils.getSession();
- TSUser tuser = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
- WarehouseEntity wh = systemService.get(WarehouseEntity.class, warehouseid);
- orders.setWarehouseName(wh.getWarehouseName());
- orders.setHandlerPersonId(tuser.getId());
- orders.setHandlerPersonName(tuser.getRealName());
- ordersFixAssetService.updateMain(orders, orderProductsList);
- 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(OrdersFixAssetEntity orders, HttpServletRequest req) {
- HttpSession session = ContextHolderUtils.getSession();
- TSUser tuser = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
- req.setAttribute("userid", tuser.getId());
- if (StringUtil.isNotEmpty(orders.getId())) {
- orders = ordersFixAssetService.getEntity(OrdersFixAssetEntity.class, orders.getId());
- dealRoundHalfUpValue(orders);
- req.setAttribute("ordersPage", orders);
- }else{
- String wareHourseId = req.getParameter("warehouseid");
- String userId = tuser.getId();
- boolean isProjectUser = UserUtil.isProjectUser(userId);
- WarehouseEntity warehouseEntity =null;
- if(StringUtils.isNotBlank(wareHourseId)) {
- warehouseEntity = systemService.getEntity(WarehouseEntity.class, wareHourseId);
- }else {//如果没有warehouseid 判断是否职能部门
- if(!isProjectUser){//职能部门 默认公司本部
- wareHourseId = "ff808081665bfece0166a8ebaa7f2738";
- warehouseEntity = systemService.getEntity(WarehouseEntity.class, wareHourseId);
- }else{
- return null;
- }
- }
- orders.setWarehouseId(wareHourseId);
- orders.setWarehouseName(warehouseEntity.getWarehouseName());
- TSDepart userDepart ;
- if(isProjectUser) {
- String departId= warehouseEntity.getProjectId();
- userDepart = systemService.getEntity(TSDepart.class,departId );
- }else{
- userDepart = useractivitiDataDao.getUserDep(userId);
- }
- orders.setDepartId(userDepart.getId());
- orders.setDepName(userDepart.getGlcName());
- orders.setOrderFor(req.getParameter("orderFor"));
- }
- req.setAttribute("ordersPage", orders);
- ModelAndView mv = new ModelAndView("cn/com/lzt/ordersfixasset/orders-add");
- if(StringUtils.isNotEmpty(orders.getOrderFor()) && orders.getOrderFor().equals("1")) {
- mv = new ModelAndView("cn/com/lzt/ordersfixasset/orders-own-add");
- }
- return mv;
- }
- /**
- * 订单表编辑页面跳转
- *
- * @return
- */
- @RequestMapping(params = "goUpdateWithProcess")
- public ModelAndView goUpdateWithProcess(OrdersFixAssetEntity orders, HttpServletRequest req) {
- if(LztUtil.isApiRequest()) {
- return goUpdateWithProcessMobile(orders, req);
- }
- String isView = req.getParameter("viewFlag");
- req.setAttribute("viewFlag", isView);
- String taskId = oConvertUtils.getString(req.getParameter("taskId"));
- HttpSession session = ContextHolderUtils.getSession();
- TSUser tuser = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
- req.setAttribute("userid", tuser.getId());
- if(oConvertUtils.isNotEmpty(taskId)){
- FormProcUtil.initWorkflowParam(req);
- req.setAttribute("taskId",taskId);
- }
- if (StringUtil.isNotEmpty(orders.getId())) {
- orders = ordersFixAssetService.getEntity(OrdersFixAssetEntity.class, orders.getId());
- dealRoundHalfUpValue(orders);
- req.setAttribute("ordersPage", orders);
- }else{
- List<String> tsDList = systemService.findListbySql("select id from t_b_warehouse where responsible_person = '"+tuser.getId()+"'");
- if(tsDList != null && tsDList.size()>0) {
- orders.setWarehouseId(tsDList.get(0));
- }
- req.setAttribute("ordersPage", orders);
- }
- // Date now = new Date();
- // Calendar begin = Calendar.getInstance();
- // begin.setTime(now);
- // begin.add(Calendar.MONTH, -2);
- //
- // Calendar end = Calendar.getInstance();
- // end.setTime(now);
- // end.add(Calendar.MONTH, 2);
- //
- // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- //
- // req.setAttribute("ref_date_begin", sdf.format(begin.getTime()));
- // req.setAttribute("ref_date_end", sdf.format(end.getTime()));
- //
- // Calendar defaultdate = Calendar.getInstance();
- // defaultdate.setTime(now);
- // int month = defaultdate.get(Calendar.MONTH);
- // if(month%2 == 0) {
- // //单月
- // month += 1;
- // }
- // defaultdate.set(Calendar.MONTH, month);
- // defaultdate.set(Calendar.DATE, 1);
- // List<String> ome = systemService.findListbySql("select id from t_b_ordermonths where ref_date='"+sdf.format(defaultdate.getTime())+"'");
- // if(ome != null && ome.size()>0) {
- // orders.setOrderMonths(ome.get(0));
- // }
- return new ModelAndView("cn/com/lzt/ordersfixasset/orders-proc-update");
- }
- @RequestMapping(params = "goUpdateWithProcessMobile")
- public ModelAndView goUpdateWithProcessMobile(OrdersFixAssetEntity orders, HttpServletRequest req) {
- String isView = req.getParameter("viewFlag");
- req.setAttribute("viewFlag", isView);
- String taskId = oConvertUtils.getString(req.getParameter("taskId"));
- HttpSession session = ContextHolderUtils.getSession();
- TSUser tuser = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
- req.setAttribute("userid", tuser.getId());
- if(oConvertUtils.isNotEmpty(taskId)){
- FormProcUtil.initWorkflowParam(req);
- req.setAttribute("taskId",taskId);
- }
- if (StringUtil.isNotEmpty(orders.getId())) {
- orders = ordersFixAssetService.getEntity(OrdersFixAssetEntity.class, orders.getId());
- dealRoundHalfUpValue(orders);
- req.setAttribute("entity", orders);
- }else{
- List<String> tsDList = systemService.findListbySql("select id from t_b_warehouse where responsible_person = '"+tuser.getId()+"'");
- if(tsDList != null && tsDList.size()>0) {
- orders.setWarehouseId(tsDList.get(0));
- }
- req.setAttribute("entity", orders);
- }
- Map<String, Object> data = LztUtil.copyReqAttributes(new String[]{
- "entity","viewFlag","taskId","userid"});
- return new JsonDataModelAndView(WXAjaxJson.success(data));
- }
- /**
- * 订单表编辑页面跳转
- *
- * @return
- */
- @RequestMapping(params = "goUpdate")
- public ModelAndView goUpdate(OrdersFixAssetEntity orders, HttpServletRequest req) {
- req.setAttribute("goUpdate", true);
- return goAdd(orders,req);
- }
- @RequestMapping(params = "goView")
- public ModelAndView goView(OrdersFixAssetEntity orders, HttpServletRequest request) {
- if(LztUtil.isApiRequest())
- return goViewMobile(orders, request);
- String taskId = oConvertUtils.getString(request.getParameter("taskId"));
- if(oConvertUtils.isNotEmpty(taskId)){
- FormProcUtil.initWorkflowParam(request);
- request.setAttribute("taskId",taskId);
- }
- if (StringUtil.isNotEmpty(orders.getId())) {
- orders = ordersFixAssetService.getEntity(OrdersFixAssetEntity.class, orders.getId());
- // idandname(req, orders);
- dealRoundHalfUpValue(orders);
- request.setAttribute("ordersPage", orders);
- }
- request.setAttribute("in_process",true);
- // return new ModelAndView("cn/com/lzt/ordersfixasset/orders-View");
- ModelAndView mv = new ModelAndView("cn/com/lzt/ordersfixasset/orders-add");
- if(orders.getOrderFor().equals("1")) {
- mv = new ModelAndView("cn/com/lzt/ordersfixasset/orders-own-add");
- }
- return mv;
- }
- @RequestMapping(params = "goViewMobile")
- public ModelAndView goViewMobile(OrdersFixAssetEntity orders, HttpServletRequest request) {
- request.setAttribute("viewFlag", "1");
- String taskId = oConvertUtils.getString(request.getParameter("taskId"));
- if(oConvertUtils.isNotEmpty(taskId)){
- FormProcUtil.initWorkflowParam(request);
- request.setAttribute("taskId",taskId);
- }
- if (StringUtil.isNotEmpty(orders.getId())) {
- orders = ordersFixAssetService.getEntity(OrdersFixAssetEntity.class, orders.getId());
- dealRoundHalfUpValue(orders);
- request.setAttribute("entity", orders);
- }
- Map<String, Object> data = LztUtil.copyReqAttributes(new String[]{
- "entity","viewFlag","taskId","load"});
- data.put("flag", request.getParameter("flag"));
- return new JsonDataModelAndView(WXAjaxJson.success(data));
- }
- // public void idandname(HttpServletRequest req, OrdersFixAssetEntity orders) {
- // WarehouseEntity warehouseEntity = systemService.findUniqueByProperty(WarehouseEntity.class, "id", orders.getWarehouseId());
- // RelatedUnitsEntity relatedUnitsEntity = systemService.findUniqueByProperty(RelatedUnitsEntity.class, "id", orders.getSupplierName());
- // TSBaseUser user = systemService.findUniqueByProperty(TSBaseUser.class, "id", orders.getHandlerPerson());
- // // 经手人
- // String handlerPersonName="";
- // // 仓库
- // String wareHouseName = "";
- // // 供应商名
- // String unitName = "";
- // if (warehouseEntity != null) {
- // wareHouseName= warehouseEntity.getWarehouseName();
- // req.setAttribute("wareHouseIdName", wareHouseName);
- // }
- // if (relatedUnitsEntity != null) {
- // unitName= relatedUnitsEntity.getUnitName();
- // req.setAttribute("textUnitName", unitName);
- // }
- //
- // if (user != null) {
- // handlerPersonName= user.getRealName();
- // req.setAttribute("realName", handlerPersonName);
- // }
- // }
- /**
- * 加载明细列表[采购商品]
- *
- * @return
- */
- @RequestMapping(params = "orderProductsList")
- public ModelAndView orderProductsList(OrdersFixAssetEntity orders, HttpServletRequest req) {
- //===================================================================================
- //获取参数
- Object id0 = orders.getId();
- orders = ordersFixAssetService.get(OrdersFixAssetEntity.class, (String)id0);
- //===================================================================================
- //查询-采购商品
- String hql0 = "from OrderFixAssetProductsEntity where 1 = 1 AND fK_ID =? ";
- try{
- List<OrderFixAssetProductsEntity> OrderFixAssetProductsEntityList = systemService.findHql(hql0,id0);
- // addOnhandInfo2OrderProdunctsList(orders,OrderFixAssetProductsEntityList);
- req.setAttribute("orderProductsList", OrderFixAssetProductsEntityList);
- String load = (String)req.getAttribute("load");
- req.setAttribute("load", load);
- }catch(Exception e){
- logger.info(e.getMessage());
- }
- String orderFor = req.getParameter("orderFor");
- if(StringUtils.equals(orderFor, "1")){
- return new ModelAndView("cn/com/lzt/ordersfixasset/orderProductsList-own");
- }
- return new ModelAndView("cn/com/lzt/ordersfixasset/orderProductsList");
- }
- /**
- * 加载审批明细列表[采购商品]
- *
- * @return
- */
- @RequestMapping(params = "orderProductsViewList")
- public ModelAndView orderProductsViewList(OrdersFixAssetEntity orders, HttpServletRequest req) {
- //===================================================================================
- //获取参数
- Object id0 = orders.getId();
- orders = ordersFixAssetService.get(OrdersFixAssetEntity.class, (String)id0);
- //===================================================================================
- //查询-采购商品
- String hql0 = "from OrderFixAssetProductsEntity where 1 = 1 AND fK_ID =? ";
- try{
- List<OrderFixAssetProductsEntity> OrderFixAssetProductsEntityList = systemService.findHql(hql0,id0);
- addOnhandInfo2OrderProdunctsList(orders,OrderFixAssetProductsEntityList);
- req.setAttribute("orderProductsList", OrderFixAssetProductsEntityList);
- String load = (String)req.getAttribute("load");
- req.setAttribute("load", load);
- }catch(Exception e){
- logger.info(e.getMessage());
- }
- return new ModelAndView("cn/com/lzt/orderproducts/orderProductsViewList");
- }
- private void addOnhandInfo2OrderProdunctsList(OrdersFixAssetEntity orders, List<OrderFixAssetProductsEntity> list) {
- if(orders != null && list != null && list.size()>0) {
- String ordermonths = orders.getOrderMonths();
- OrderMonthsEntity ordermonthsEntity = systemService.get(OrderMonthsEntity.class, ordermonths);
- String warehouseid = orders.getWarehouseId();
- DateFormat format = new SimpleDateFormat("yyyy-MM");
- String busiDate = format.format(ordermonthsEntity.getRefDate());
- //暂时使用旧接口,带新功能启用后,再使用新接口
- HashMap<String,HashMap<String,Double>> onHandMap = ordersFixAssetService.queryGoodsOnhandDataForOrderAudit(busiDate,warehouseid, list);
- if(onHandMap != null) {
- for(OrderFixAssetProductsEntity entity : list) {
- String goodsid = entity.getGoodsId();
- String unit = entity.getMeasureUnit();
- HashMap<String,Double> result = onHandMap.get(goodsid+unit);
- if(result != null) {
- Double onhand = result.get(SCMConsole.ONHAND);
- Double last2MonthOutQuantity = result.get(SCMConsole.LAST2MONTHOUTQUANTITY);
- entity.setLastMonthUsedAmount(last2MonthOutQuantity);
- entity.setOnHandAmount(onhand);
- }
- }
- }
- }
- }
- /**
- * 加载审批明细可修改列表[采购商品]
- *
- * @return
- */
- @RequestMapping(params = "orderProductsProcUpdateList")
- public ModelAndView orderProductsProcUpdateList(OrdersFixAssetEntity orders, HttpServletRequest req) {
- //===================================================================================
- //获取参数
- Object id0 = orders.getId();
- orders = ordersFixAssetService.get(OrdersFixAssetEntity.class, (String)id0);
- //===================================================================================
- //查询-采购商品
- try{
- List<OrderFixAssetProductsEntity> OrderFixAssetProductsEntityList = ordersFixAssetDao.getOrderProductsOrderByCategory((String)id0);
- addOnhandInfo2OrderProdunctsList(orders,OrderFixAssetProductsEntityList);
- req.setAttribute("orderProductsList", OrderFixAssetProductsEntityList);
- String load = (String)req.getAttribute("load");
- req.setAttribute("load", load);
- }catch(Exception e){
- logger.info(e.getMessage());
- }
- return new ModelAndView("cn/com/lzt/orderproducts/orderProductsProcUpdateList");
- }
- /**
- * 导出excel
- *
- * @param request
- * @param response
- */
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @RequestMapping(params = "exportXls")
- public String exportXls(OrdersFixAssetEntity orders,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid,ModelMap map) {
- CriteriaQuery cq = new CriteriaQuery(OrdersFixAssetEntity.class, dataGrid);
- String orderDateBegin = request.getParameter("orderDate_begin");
- String orderDateEnd = request.getParameter("orderDate_end");
- // 模糊查询
- String orderOnumber = orders.getOrderOnumber();
- if(StringUtils.isNotBlank(orderOnumber)){
- orders.setOrderOnumber("*" +orderOnumber +"*");
- }
- //查询条件组装器
- HqlGenerateUtil.installHql(cq, orders);
- try{
- //自定义追加查询条件
- if(StringUtils.isNotBlank(orderDateBegin) && StringUtils.isNotBlank(orderDateEnd)){
- cq.ge("orderDate", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(orderDateBegin + " 00:00:00"));
- cq.le("orderDate", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(orderDateEnd + " 23:59:59"));
- }
- }catch (Exception e) {
- throw new BusinessException(e.getMessage());
- }
- cq.add();
- List<OrdersFixAssetEntity> list=this.ordersFixAssetService.getListByCriteriaQuery(cq, false);
- List<OrdersFixAssetEntity> listResult = null;
- List<OrdersFixAssetPage> pageList=new ArrayList<OrdersFixAssetPage>();
- List<OrderFixAssetProductsEntity> OrderFixAssetProductsEntityListResult = null;
- if(list!=null&&list.size()>0){
- Class clsOrder = MyClassLoader.getClassByScn("cn.com.lzt.orders.entity.OrdersFixAssetEntity");
- try {
- listResult =systemService.dealResultShowText4Entities(list, clsOrder);
- } catch (Exception e1) {
- logger.info(e1.getMessage());
- }
- for(OrdersFixAssetEntity entity:listResult){
- try{
- OrdersFixAssetPage page=new OrdersFixAssetPage();
- MyBeanUtils.copyBeanNotNull2Bean(entity,page);
- Object id0 = entity.getId();
- String hql0 = "from OrderFixAssetProductsEntity where 1 = 1 AND fK_ID =? ";
- List<OrderFixAssetProductsEntity> OrderFixAssetProductsEntityList = systemService.findHql(hql0,id0);
- Class cls = MyClassLoader.getClassByScn("cn.com.lzt.orderproducts.entity.OrderFixAssetProductsEntity");
- OrderFixAssetProductsEntityListResult =systemService.dealResultShowText4Entities(OrderFixAssetProductsEntityList, cls);
- page.setOrderProductsList(OrderFixAssetProductsEntityListResult);
- pageList.add(page);
- }catch(Exception e){
- logger.info(e.getMessage());
- }
- }
- }
- map.put(NormalExcelConstants.FILE_NAME,"订单表");
- map.put(NormalExcelConstants.CLASS,OrdersFixAssetPage.class);
- map.put(NormalExcelConstants.PARAMS,new ExportParams("订单表列表", "导出人:Jeecg",
- "导出信息"));
- map.put(NormalExcelConstants.DATA_LIST,pageList);
- return NormalExcelConstants.JEECG_EXCEL_VIEW;
- }
- /**
- * 导出excel
- *
- * @param request
- * @param response
- */
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @RequestMapping(params = "exportXlsOrder")
- public String exportXlsOrder(String orderid,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid,ModelMap map) {
- TSUser user = ResourceUtil.getSessionUser();
- OrdersFixAssetEntity order = systemService.get(OrdersFixAssetEntity.class, orderid);
- List<OrderFixAssetProductsEntity> details = systemService.findByProperty(OrderFixAssetProductsEntity.class, "fkId", orderid);
- map.put(NormalExcelConstants.FILE_NAME,"申购单-"+order.getWarehouseName());
- map.put(NormalExcelConstants.CLASS,OrderFixAssetProductsEntity.class);
- ExportParams param = new ExportParams("申购单-"+order.getWarehouseName() ,"导出信息");
- param.setAddIndex(true);
- map.put(NormalExcelConstants.PARAMS,param);
- map.put(NormalExcelConstants.DATA_LIST,details);
- return NormalExcelConstants.JEECG_EXCEL_VIEW;
- }
- /**
- * 通过excel导入数据
- * @param request
- * @param
- * @return
- */
- @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(2);
- params.setNeedSave(true);
- try {
- List<OrdersFixAssetPage> list = ExcelImportUtil.importExcel(file.getInputStream(), OrdersFixAssetPage.class, params);
- OrdersFixAssetEntity entity1=null;
- for (OrdersFixAssetPage page : list) {
- entity1=new OrdersFixAssetEntity();
- MyBeanUtils.copyBeanNotNull2Bean(page,entity1);
- ordersFixAssetService.addMain(entity1, page.getOrderProductsList());
- }
- j.setMsg("文件导入成功!");
- } catch (Exception e) {
- j.setMsg("文件导入失败!");
- logger.error(ExceptionUtil.getExceptionMessage(e));
- }finally{
- try {
- file.getInputStream().close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- return j;
- }
- /**
- * 导出excel 使模板
- */
- @RequestMapping(params = "exportXlsByT")
- public String exportXlsByT(ModelMap map) {
- map.put(NormalExcelConstants.FILE_NAME,"订单表");
- map.put(NormalExcelConstants.CLASS,OrdersFixAssetPage.class);
- map.put(NormalExcelConstants.PARAMS,new ExportParams("订单表列表", "导出人:"+ ResourceUtil.getSessionUserName().getRealName(),
- "导出信息"));
- map.put(NormalExcelConstants.DATA_LIST,new ArrayList());
- return NormalExcelConstants.JEECG_EXCEL_VIEW;
- }
- /**
- * 导入功能跳转
- *
- * @return
- */
- @RequestMapping(params = "upload")
- public ModelAndView upload(HttpServletRequest req) {
- req.setAttribute("controller_name", "ordersController");
- return new ModelAndView("common/upload/pub_excel_upload");
- }
- @RequestMapping(method = RequestMethod.GET)
- @ResponseBody
- public List<OrdersFixAssetEntity> list() {
- List<OrdersFixAssetEntity> listOrderss=ordersFixAssetService.getList(OrdersFixAssetEntity.class);
- return listOrderss;
- }
- @RequestMapping(value = "/{id}", method = RequestMethod.GET)
- @ResponseBody
- public ResponseEntity<?> get(@PathVariable("id") String id) {
- OrdersFixAssetEntity task = ordersFixAssetService.get(OrdersFixAssetEntity.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 OrdersFixAssetPage ordersPage, UriComponentsBuilder uriBuilder) {
- //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息.
- Set<ConstraintViolation<OrdersFixAssetPage>> failures = validator.validate(ordersPage);
- if (!failures.isEmpty()) {
- return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
- }
- //保存
- List<OrderFixAssetProductsEntity> orderProductsList = ordersPage.getOrderProductsList();
- OrdersFixAssetEntity orders = new OrdersFixAssetEntity();
- try{
- MyBeanUtils.copyBeanNotNull2Bean(orders,ordersPage);
- }catch(Exception e){
- logger.info(e.getMessage());
- }
- ordersFixAssetService.addMain(orders, orderProductsList);
- //按照Restful风格约定,创建指向新任务的url, 也可以直接返回id或对象.
- String id = ordersPage.getId();
- URI uri = uriBuilder.path("/rest/ordersController/" + 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 OrdersFixAssetPage ordersPage) {
- //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息.
- Set<ConstraintViolation<OrdersFixAssetPage>> failures = validator.validate(ordersPage);
- if (!failures.isEmpty()) {
- return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
- }
- //保存
- List<OrderFixAssetProductsEntity> orderProductsList = ordersPage.getOrderProductsList();
- OrdersFixAssetEntity orders = new OrdersFixAssetEntity();
- try{
- MyBeanUtils.copyBeanNotNull2Bean(orders,ordersPage);
- }catch(Exception e){
- logger.info(e.getMessage());
- }
- ordersFixAssetService.updateMain(orders, orderProductsList);
- //按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) {
- OrdersFixAssetEntity orders = ordersFixAssetService.get(OrdersFixAssetEntity.class, id);
- ordersFixAssetService.delMain(orders);
- }
-
- /**
- * 解析SQL,返回字段集 支持多数据源
- * @return
- */
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @RequestMapping(params = "getProductInfo", method = RequestMethod.POST)
- @ResponseBody
- public Object getSqlFields(String goodsCode){
- TBGoodsInfoEntity goodInfo = null;
- TBPriceInfoEntity tBPriceInfoEntity = null;
- TBPriceInfoEntity tBPriceInfoEntityResult = null;
- Map reJson = new HashMap<String, Object>();
- try{
- //goodInfo = systemService.findUniqueByProperty(TBGoodsInfoEntity.class, "goodsCode",goodsCode);
- String hql_Goods = "from TBGoodsInfoEntity where 1 = 1 AND GOODS_CODE =? AND STATUS = 0 AND DELETE_FLAG = 0";
- List<TBGoodsInfoEntity> tBGoodsInfoEntityList = systemService.findHql(hql_Goods,goodsCode);
- if(tBGoodsInfoEntityList != null && tBGoodsInfoEntityList.size() > 0){
- goodInfo = tBGoodsInfoEntityList.get(0);
- }else{
- reJson.put("status", "false");
- return reJson;
- }
- String categoryHql = " FROM TBGoodsCategoryEntity where categoryCode =? or categoryCode =? order by categoryCode";
- List<TBGoodsCategoryEntity> categoryList = systemService.findHql(categoryHql,goodInfo.getBelongCategoryCode().substring(0,7),goodInfo.getBelongCategoryCode().substring(0,10));
- if(categoryList != null && categoryList.size() == 2) {
- goodInfo.setCategoryname(categoryList.get(0).getCategoryName()+"-"+categoryList.get(1).getCategoryName());
- }else {
- reJson.put("status", "false");
- return reJson;
- }
- //获取参数
- Object id0 = goodInfo.getId();
- String hql0 = "from TBPriceInfoEntity where 1 = 1 AND GOODS_ID =? ";
- List<TBPriceInfoEntity> tBPriceInfoEntityList = systemService.findHql(hql0,id0);
- if(tBPriceInfoEntityList != null && tBPriceInfoEntityList.size() > 0){
- for(int i = 0 ;i < tBPriceInfoEntityList.size();i++){
- tBPriceInfoEntity = new TBPriceInfoEntity();
- tBPriceInfoEntity = tBPriceInfoEntityList.get(i);
- if(goodInfo.getPurchaseUnit() != null && tBPriceInfoEntity.getMeteringUnit() != null && goodInfo.getPurchaseUnit().equals(tBPriceInfoEntity.getMeteringUnit())){
- tBPriceInfoEntityResult = tBPriceInfoEntity;
- break;
- }
- }
- }
- }catch (Exception e) {
- logger.info(e.getMessage());
- }
- reJson.put("status", "success");
- reJson.put("datainfo", goodInfo);
- reJson.put("pricinfo", tBPriceInfoEntityResult);
- return reJson;
- }
-
- /**
- * 解析SQL,返回字段集 支持多数据源
- * @return
- */
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @RequestMapping(params = "getPurchasePriceInfo", method = RequestMethod.POST)
- @ResponseBody
- public Object getPurchasePriceInfo(String goodsCode,String purchaseUnit){
- Map reJson = new HashMap<String, Object>();
- TBGoodsInfoEntity goodInfo = null;
- if(StringUtils.isNotBlank(goodsCode) && StringUtils.isNotBlank(purchaseUnit)){
- TBPriceInfoEntity tBPriceInfoEntityResult = null;
- List<String> unitlist = new ArrayList<String>();
- try{
- goodInfo = systemService.findUniqueByProperty(TBGoodsInfoEntity.class, "goodsCode",goodsCode);
- String hql0 = "from TBPriceInfoEntity where 1 = 1 AND GOODS_ID = ?";
- List<TBPriceInfoEntity> tBPriceInfoEntityList = systemService.findHql(hql0,goodInfo.getId());
- if(tBPriceInfoEntityList != null && tBPriceInfoEntityList.size() > 0){
- for(TBPriceInfoEntity price : tBPriceInfoEntityList) {
- unitlist.add(price.getMeteringUnit());
- if(purchaseUnit.equals(price.getMeteringUnit())) {
- tBPriceInfoEntityResult = price;
- }
- }
- }
- if(tBPriceInfoEntityResult == null) {
- List<DictEntity> dictList = jeecgDictDao.querySystemDict("metering_calcu_unit");
- HashMap<String, String> map = new HashMap<>();
- for(DictEntity dic : dictList) {
- map.put(dic.getTypecode(), dic.getTypename());
- }
- StringBuffer sb = new StringBuffer();
- sb.append("可选择的计量单位:【");
- for(int i=0 ; i<unitlist.size() ; i++) {
- if(i>0) {
- sb.append("/");
- }
- sb.append(map.get(unitlist.get(i)));
- }
- sb.append("】");
- reJson.put("msg", sb.toString());
- }
- }catch (Exception e) {
- reJson.put("status", "fail");
- logger.info(e.getMessage());
- return reJson;
- }
- reJson.put("status", "success");
- reJson.put("pricinfo", tBPriceInfoEntityResult);
- }else{
- reJson.put("status", "success");
- reJson.put("pricinfo", null);
-
- }
- return reJson;
- }
-
- /**
- * @param categoryName
- * @param categoryName
- * @return
- */
- private String dealCateName(String categoryCode, String categoryName) {
- if(categoryCode.contains("rootA04")) {
- categoryName = "固定资产类-" + categoryName;
- }else if(categoryCode.contains("rootA05")) {
- categoryName = "应急采购类-" + categoryName;
- }else if(categoryCode.contains("rootA06")) {
- categoryName = "其他类-" + categoryName;
- }
- return categoryName;
- }
- /**
- * 经手人弹出框
- * @param request
- * @param response
- * @param dataGrid
- * @throws ClassNotFoundException
- */
- @SuppressWarnings({"rawtypes" })
- @RequestMapping(params = "selRefDatagridHandlerPerson")
- public void selRefDatagridHandlerPerson(String classname,TSBaseUser tSBaseUser,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) throws Exception {
- // Class cls = MyClassLoader.getClassByScn(classname);
- // CriteriaQuery cq = new CriteriaQuery(cls, dataGrid);
- // //自定义追加查询条件
- // Short[] status = new Short[]{Globals.ONLINE,Globals.OFFLINE};
- // cq.in("status", status);
- // cq.eq("deleteFlag", Globals.Delete_Normal);
- // // 检索用仓库编码
- // if(StringUtils.isNotBlank(tSBaseUser.getUserName())){
- // cq.eq("userName", tSBaseUser.getUserName());
- // }
- // // 检索用仓库名称
- // if(StringUtils.isNotBlank(tSBaseUser.getRealName())){
- // cq.eq("realName", tSBaseUser.getRealName());
- // }
- // org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, cls.newInstance());
- // commonDao.getDataGridReturn(cq, true);
- // List result = dataGrid.getResults();
- // try {
- // //result =systemService.dealResultShowText4Entities(dataGrid.getResults(), cls);
- // } catch (Exception e) {
- // throw new BusinessException(e);
- // }
- // dataGrid.setResults(result);
- // TagUtil.datagrid(response, dataGrid);
- }
- /**
- * 经手人弹出框
- * @return
- */
- @RequestMapping(params = "selectReferHandlerPerson")
- public ModelAndView selectReferHandlerPerson(HttpServletRequest request) {
- ModelAndView mv = new ModelAndView("cn/com/lzt/ordersfixasset/selectHandlerPersonInfo");
- String ids = oConvertUtils.getString(request.getParameter("ids"));
- mv.addObject("ids", ids);
- // 需要将前端的类路径传递到refer页面
- String clsname = oConvertUtils.getString(request.getParameter("classname"));
- mv.addObject("classname", clsname);
- mv.addObject("codefield", oConvertUtils.getString(request.getParameter("codefield")));
- mv.addObject("namefield", oConvertUtils.getString(request.getParameter("namefield")));
- return mv;
- }
- /**
- * 物流弹出框
- * @param request
- * @param response
- * @param dataGrid
- * @throws ClassNotFoundException
- */
- @SuppressWarnings({"rawtypes" })
- @RequestMapping(params = "selRefDatagridLogistics")
- public void selRefDatagridLogistics(String classname,TBLogisticsEntity tBLogisticsEntity,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) throws Exception {
- Class cls = MyClassLoader.getClassByScn(classname);
- CriteriaQuery cq = new CriteriaQuery(cls, dataGrid);
- //自定义追加查询条件
- String[] unitstate = new String[]{Globals.Enable_Normal};
- cq.in("status", unitstate);
- cq.eq("deleteFlag", Globals.Delete_Normal.toString());
- // 检索用仓库编码
- if(StringUtils.isNotBlank(tBLogisticsEntity.getCompanyCode())){
- cq.eq("companyCode", tBLogisticsEntity.getCompanyCode());
- }
- // 检索用仓库名称
- if(StringUtils.isNotBlank(tBLogisticsEntity.getCompanyName())){
- cq.eq("companyName", tBLogisticsEntity.getCompanyName());
- }
- HqlGenerateUtil.installHql(cq, cls.newInstance());
- commonDao.getDataGridReturn(cq, true);
- List result = dataGrid.getResults();
- try {
- //result =systemService.dealResultShowText4Entities(dataGrid.getResults(), cls);
- } catch (Exception e) {
- throw new BusinessException(e);
- }
- dataGrid.setResults(result);
- TagUtil.datagrid(response, dataGrid);
- }
- /**
- * 物流弹出框
- * @return
- */
- @RequestMapping(params = "selectReferLogistics")
- public ModelAndView selectReferLogistics(HttpServletRequest request) {
- ModelAndView mv = new ModelAndView("cn/com/lzt/ordersfixasset/selectLogisticsInfo");
- String ids = oConvertUtils.getString(request.getParameter("ids"));
- mv.addObject("ids", ids);
- // 需要将前端的类路径传递到refer页面
- String clsname = oConvertUtils.getString(request.getParameter("classname"));
- mv.addObject("classname", clsname);
- mv.addObject("codefield", oConvertUtils.getString(request.getParameter("codefield")));
- mv.addObject("namefield", oConvertUtils.getString(request.getParameter("namefield")));
- return mv;
- }
- /**
- * 取消采购单
- *
- * @author guoqing.yan
- */
- @RequestMapping(params = "doCancel")
- @ResponseBody
- public AjaxJson doCancel(String id, HttpServletRequest req) {
- AjaxJson j = new AjaxJson();
- String message = null;
- OrdersFixAssetEntity orders = ordersFixAssetService.getEntity(OrdersFixAssetEntity.class, id);
- try{
- // 未审批和已经审批的可以取消
- if(orders.getOrderStatus() != null &&(orders.getOrderStatus().equals(Globals.UNAPPROVED) || orders.getOrderStatus().equals(Globals.APPROVED))){
- orders.setOrderStatus(Globals.CANCELED);//订单状态: 取消
- ordersFixAssetService.updateEntitie(orders);
- message = "单号:" + orders.getOrderOnumber() + "取消成功!";
- systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
- }else{
- message = "该单不能取消,请确认!";
- }
- }catch(Exception e){
- message = "操作失败!";
- }
- j.setMsg(message);
- return j;
- }
-
- private void dealRoundHalfUpValue(OrdersFixAssetEntity entity) {
- BigDecimal guding = entity.getGudingSum() == null ? BigDecimal.ZERO : new BigDecimal(entity.getGudingSum());
- entity.setGudingSum(guding.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
- BigDecimal yingji = entity.getYingjiSum() == null ? BigDecimal.ZERO : new BigDecimal(entity.getYingjiSum());
- entity.setYingjiSum(yingji.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
- BigDecimal qita = entity.getQitaSum() == null ? BigDecimal.ZERO : new BigDecimal(entity.getQitaSum());
- entity.setQitaSum(qita.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
- }
- /**
- * 取消采购单
- *
- * @author guoqing.yan
- */
- @RequestMapping(params = "doCancelAuditOrder")
- @ResponseBody
- public AjaxJson doCancelAuditOrder(String id,String refundvalue, HttpServletRequest req) {
- AjaxJson j = new AjaxJson();
- String message = null;
- OrdersFixAssetEntity orders = ordersFixAssetService.getEntity(OrdersFixAssetEntity.class, id);
- // try{
- // // 首先判断该订单是否入库,如果入库则不能取消
- // Long godownOrderCount = systemService.getCountForJdbc("select count(1) from t_b_godown_entry where purchase_order_no='" + orders.getOrderOnumber() + "'");
- // // 未入库时候
- // if(godownOrderCount <=0){
- // if(StringUtils.isNotBlank(refundvalue)){
- // // 退的预付定金额
- // Double refundMoney = Double.parseDouble(refundvalue);
- // CollectMiddleEntity collectMiddleEntity = new CollectMiddleEntity();
- // collectMiddleEntity.setUnitId(orders.getSupplierId());// 供应商ID
- // collectMiddleEntity.setCollectionOrderOnumber(orders.getOrderOnumber());//订单号
- // collectMiddleEntity.setCollectionType(Globals.DEPOSIT_REFUND);// 预付定金退款
- // collectMiddleEntity.setAmountReceivable(refundMoney);
- // collectMiddleService.saveOrUpdate(collectMiddleEntity);
- // // 更新 往来单位表中的 应收余额
- // RelatedUnitsEntity relatedUnitsEntity = relatedUnitsService.get(RelatedUnitsEntity.class, orders.getSupplierId());
- // if(relatedUnitsEntity.getAmountReceivable() != null){
- // relatedUnitsEntity.setPrepaidBalance(refundMoney + relatedUnitsEntity.getAmountReceivable());// 预付余额
- // }else{
- // relatedUnitsEntity.setPrepaidBalance(refundMoney);// 预付余额
- // }
- // relatedUnitsService.updateEntitie(relatedUnitsEntity);
- // }
- // // 未审批和已经审批的可以取消
- // if(orders.getOrderStatus() != null && !orders.getOrderStatus().equals(Globals.CANCELED)){
- // orders.setOrderStatus(Globals.CANCELED);//订单状态: 取消
- // ordersFixAssetService.updateEntitie(orders);
- // message = "单号:" + orders.getOrderOnumber() + "取消成功!";
- // systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
- // }else{
- // message = "该单已经取消,请确认!";
- // }
- // // 已经入库的时候
- // }else{
- // message = "该订单已经入库,不能取消,请确认!";
- // }
- //
- // }catch(Exception e){
- // message = "操作失败!";
- // }
- j.setMsg(message);
- return j;
- }
-
- /**
- * 审核通过 采购单
- *
- * @author guoqing.yan
- */
- @RequestMapping(params = "doAudit")
- @ResponseBody
- public AjaxJson doAudit(String id, HttpServletRequest req) {
- AjaxJson j = new AjaxJson();
- String message = null;
- OrdersFixAssetEntity orders = ordersFixAssetService.getEntity(OrdersFixAssetEntity.class, id);
- try{
- // 未审批和已经审批的可以取消
- if(orders.getOrderStatus() != null &&orders.getOrderStatus().equals(Globals.UNAPPROVED)){
- // 预付定金 不为空的时候
- if(orders.getPrepaidMoney() != null && orders.getPrepaidMoney() >0){
- // 更新 付款明细中间表
- // PaymentMiddleEntity paymentMiddleEntity = new PaymentMiddleEntity();
- // paymentMiddleEntity.setUnitId(orders.getSupplierId());// 供应商ID
- // paymentMiddleEntity.setPaymentDate(new Date());// 应付款发生日期
- // paymentMiddleEntity.setPaymentOrderOnumber(orders.getOrderOnumber());// 应付款单据编号
- // paymentMiddleEntity.setPaymentType(Globals.PURCHASE_ADVANCE_PAYMENT);// 应付款类型 采购预付款
- // paymentMiddleEntity.setHandlerPerson(orders.getHandlerPersonId());// 经手人
- // paymentMiddleEntity.setAmountPayable(orders.getPrepaidMoney());// 应付定金
- // paymentMiddleService.save(paymentMiddleEntity);
- // 更新 往来单位表中的 预付余额
- RelatedUnitsEntity relatedUnitsEntity = relatedUnitsService.get(RelatedUnitsEntity.class, orders.getSupplierId());
- if(relatedUnitsEntity.getPrepaidBalance() != null){
- relatedUnitsEntity.setPrepaidBalance(orders.getPrepaidMoney() + relatedUnitsEntity.getPrepaidBalance());// 预付余额
- }else{
- relatedUnitsEntity.setPrepaidBalance(orders.getPrepaidMoney());// 预付余额
- }
- relatedUnitsService.updateEntitie(relatedUnitsEntity);
- }
- // 采购单审核状态更新
- ordersFixAssetService.updateEntitie(orders);
- HttpSession session = ContextHolderUtils.getSession();
- TSUser tuser = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
- orders.setAuditDate(new Date());
- orders.setOrderAuditor(tuser.getRealName());
- orders.setOrderStatus(Globals.APPROVED);//订单状态: 已审批
- message = "单号:" + orders.getOrderOnumber() + "已生效!";
- systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
- }else{
- message = "该单已经取消或者已生效,不能提交生效,请确认!";
- }
- }catch(Exception e){
- message = "操作失败!";
- }
- j.setMsg(message);
- return j;
- }
- @RequestMapping(params = "doCheckNotSubnitWarehouse")
- @ResponseBody
- public AjaxJson doCheckNotSubnitWarehouse(String id,String refundvalue, HttpServletRequest req) {
- AjaxJson j = new AjaxJson();
- String message = null;
- try {
- String monthSql = "select id from t_b_ordermonths where ref_date = ?";
- String monthFirstDay = DateUtils.date_sdf.format(new Date()).substring(0, 7)+"-01";
- if (monthFirstDay.substring(5, 7).equals("01") || monthFirstDay.substring(5, 7).equals("03") ||monthFirstDay.substring(5, 7).equals("05") ||
- monthFirstDay.substring(5, 7).equals("07") ||monthFirstDay.substring(5, 7).equals("09") ||monthFirstDay.substring(5, 7).equals("11")) {
- Calendar cal = Calendar.getInstance();
- cal.setTime(new Date());
- cal.add(Calendar.MONTH, -1);
- Date lastMonthDate = cal.getTime();
- monthFirstDay = DateUtils.date_sdf.format(lastMonthDate).substring(0, 7)+"-01";
- }
- List<Map<String,Object>> res = systemService.findForJdbc(monthSql, monthFirstDay);
- if(res.size() == 0)
- return j;
- wxservice.sendMsgToWXForOrdersNotSubmit(res.get(0).get("id").toString());
- message = "消息发送成功,请行政经理查看美都环卫微管理";
- }catch (Exception e) {
- logger.error(e.getMessage());
- message = "操作失败,请联系系统管理员查看失败原因。";
- }
- j.setMsg(message);
- return j;
- }
-
- @RequestMapping(params = "checkGoAdd")
- @ResponseBody
- public AjaxJson checkGoAdd(String warehouseid, HttpServletRequest request) {
- AjaxJson j = new AjaxJson();
- //暂时取消校验,待物料二期正式使用时,在启用此校验
- // if(true)
- // return j;
- TSUser tuser = ResourceUtil.getSessionUser();
- if(StringUtils.isEmpty(warehouseid)){
- List<String> tsDList = systemService.findListbySql("select id from t_b_warehouse where responsible_person = '"+tuser.getId()+"'");
- if(tsDList != null && tsDList.size()>0) {
- warehouseid = tsDList.get(0);
- }
- }
- String message = "";
- String lastMonth = XcglDateUtils.addDateMonth(new Date(), -1, DateUtils.date_sdf).substring(0,7);
- //查询上个月出库单
- String noStorageOutSql = "select * from t_b_storage_out where warehouseid =? and left(outdate,7) =? ";
- String onhandSql = "select * from t_b_onhandreport where warehouse_id =? and order_date =? ";
- String hasPorderSql = "select id from t_b_porders where warehouse_id = '"+warehouseid+"' and left(order_date,4) > '2019' order by order_date desc LIMIT 1";
- String orderstotalSql = "select count(*) as totalrows from t_b_orders where warehouse_id =? ";
- //新建领料点,可以直接申请物料
- List<Map<String,Object>> ordersCount = systemService.findForJdbc(orderstotalSql, warehouseid);
- if(Integer.parseInt(ordersCount.get(0).get("totalrows").toString()) == 0)
- return j;
- List<String> idList = systemService.findListbySql(hasPorderSql);
- //查询上一个采购单的核对单
- String noStorageInSql = "select * from t_b_storage_in where porderid in ( select id from ( " +
- "select id from t_b_porders where warehouse_id =? order by order_date desc LIMIT 1 )as t)" ;
- List<Map<String,Object>> retout = systemService.findForJdbc(noStorageOutSql, warehouseid,lastMonth);
- List<Map<String,Object>> retOnhand = systemService.findForJdbc(onhandSql, warehouseid,lastMonth);
- List<Map<String,Object>> retin = systemService.findForJdbc(noStorageInSql, warehouseid);
- //如果上个月库存上报单及领料出库单都没有,则提示,保障系统初始运行时无错误逻辑
- if(retOnhand.size() == 0 && retout.size() == 0 ){
- message = lastMonth+"未进行领料出库,请填写领料出库后再进行物料申购";
- }
- //如果有采购单,并且采购单没有进行核对,则提示
- if(idList.size() > 0 && retin.size() == 0){
- message = "此领料点上次采购单未进行采购核对,请填写采购单核对后再进行物料申购";
- }
- if(StringUtils.isNotEmpty(message)) {
- j.setSuccess(false);
- j.setMsg(message);
- }
- return j;
- }
- @RequestMapping(params="exportDetailPdf4Mobile")
- public void exportDetailPdf4Mobile(
- @RequestParam("procInstId") String procInstId
- ,@RequestParam(value = "flag",required = false,defaultValue = "2") Integer flag
- ,HttpServletRequest request, HttpServletResponse response){
- ActivitiTools tools = ActivitiTools.getInstance(procInstId,true);
- tools.setProcInstId(null);
- ActivitiPdfExport pdfExport = tools.getPdfExport();
- String id = tools.getBusId();
- OrdersFixAssetEntity orders = ordersFixAssetService.getEntity(OrdersFixAssetEntity.class, id);
- String orderFor= orders.getOrderFor();
- String orderForTxt;
- if(orderFor.equals("0")){
- orderForTxt="公司采购";
- }else{
- orderForTxt="自行采购";
- }
- boolean showMoney = (flag>=3 || orderFor.equals("1"));
- pdfExport.table()
- .cell("领料点",orders.getWarehouseName()).cell("采购方式",orderForTxt).cell("组织机构",orders.getDepName());
- if(showMoney) {
- pdfExport.cell("总金额", orders.getTotalMoney() == null ? "0" : orders.getTotalMoney().toString());
- /*.cell("固定资产类金额", orders.getGudingSum() == null ? "0" : orders.getGudingSum().toString())
- .cell("应急采购类金额", orders.getYingjiSum() == null ? "0" : orders.getYingjiSum().toString())
- .cell("其他类金额", orders.getQitaSum() == null ? "0" : orders.getQitaSum().toString());*/
- }
- pdfExport.cell("备注说明",orders.getDescription());
- String hql0 = "from OrderFixAssetProductsEntity where 1 = 1 AND fK_ID =? ";
- try{
- List<OrderFixAssetProductsEntity> OrderFixAssetProductsEntityList = systemService.findHql(hql0,id);
- pdfExport.cell("");
- int detailColumnNum =showMoney?7:5;
- PdfPTable detailTableHeader = pdfExport.createTable(detailColumnNum);
- detailTableHeader.setWidthPercentage(100);
- pdfExport.cell(detailTableHeader, "货品名称", true);
- pdfExport.cell(detailTableHeader, "货品分类", true);
- pdfExport.cell(detailTableHeader, "计量单位", true);
- pdfExport.cell(detailTableHeader, "数量", true);
- if(showMoney) {
- pdfExport.cell(detailTableHeader, "采购单价(元)", true);
- pdfExport.cell(detailTableHeader, "金额(元)", true);
- }
- pdfExport.cell(detailTableHeader, "备注", true);
- pdfExport.cell(detailTableHeader);
- int i = 0;
- for(OrderFixAssetProductsEntity detailEntity:OrderFixAssetProductsEntityList){
- i++;
- PdfPTable detailTable = pdfExport.createTable(detailColumnNum);
- pdfExport.cell(detailTable,detailEntity.getPname(),false);
- pdfExport.cell(detailTable, detailEntity.getBelongCategoryName(), false);
- pdfExport.cell(detailTable, DictUtil.formatToTypeName(detailEntity.getMeasureUnit(),"metering_calcu_unit") , false);
- pdfExport.cell(detailTable, detailEntity.getQuantity().toString(), false);
- if(showMoney) {
- pdfExport.cell(detailTable, detailEntity.getPurchasePrice().toString(), false);
- pdfExport.cell(detailTable, detailEntity.getMoney().toString(), false);
- }
- pdfExport.cell(detailTable,detailEntity.getRemark(), false);
- pdfExport.cell("明细"+i,true);
- pdfExport.cell(detailTable);
- }
- }catch(Exception e){
- e.printStackTrace();
- logger.info(e.getMessage());
- }
- tools.exportToResponse(response);
- }
- /**
- * 选择物料签报单 员工报销
- * @return
- */
- @RequestMapping(params = "ordersFixAssetSelect4CostPay")
- public String ordersFixAssetSelect4CostPay(){
- return "cn/com/lzt/ordersfixasset/select_orders_fix_asset_cost_pay";
- }
- @RequestMapping(params = "ordersFixAssetSelect4CostPayDatagrid")
- public void ordersFixAssetSelect4CostPayDatagrid(OrdersFixAssetEntity entity, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid){
- TSUser user = ResourceUtil.getSessionUser();
- boolean projectUser = UserUtil.isProjectUser(user.getId());
- // List<String> warehouseIdList = getUserWarehouse();
- String role = userService.getUserRole(user);
- if(!StringUtils.contains(role, Globals.POSITION_TYPE_XZBFJL)){
- entity.setCreateBy(user.getUserName());
- entity.setOrderFor("1");
- }
- List<OrdersFixAssetEntity> ordersList =ordersFixAssetDao.getOrders4CostPay(entity,user.getId(),projectUser,null);
- dataGrid.setResults(ordersList);
- dataGrid.setTotal(ordersList.size());
- TagUtil.datagrid(response, dataGrid);
- }
- /**
- * 选择物料签报详情单 对外付款
- * @return
- */
- @RequestMapping(params = "ordersFixAssetDetailSelect4CostPay")
- public String ordersFixAssetDetailSelect4CostPay(){
- return "cn/com/lzt/ordersfixasset/select_orders_fix_asset_detail_cost_pay";
- }
- @RequestMapping(params = "ordersFixAssetDetailSelect4CostPayDatagrid")
- public void ordersFixAssetDetailSelect4CostPayDatagrid(OrderFixAssetProductsEntity entity, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid){
- TSUser user = ResourceUtil.getSessionUser();
- boolean projectUser = UserUtil.isProjectUser(user.getId());
- // List<String> warehouseIdList = getUserWarehouse();
- entity.setId(request.getParameter("updateId"));
- String role = userService.getUserRole(user);
- if(!StringUtils.contains(role, Globals.POSITION_TYPE_XZBFJL)){
- entity.setCreateBy(user.getUserName());
- entity.setOrderFor("1");
- }
- List<OrderFixAssetProductsEntity> ordersList =ordersFixAssetDao.getOrderProducts4CostPay(entity,user.getId(),projectUser,null);
- dataGrid.setResults(ordersList);
- dataGrid.setTotal(ordersList.size());
- TagUtil.datagrid(response, dataGrid);
- }
- }
|