YYC
2023-10-21 6fbd63022d55e31cffd60b4e390d608e474e99c0
账面库存
已添加3个文件
540 ■■■■■ 文件已修改
igds-core/src/main/java/com/ld/igds/view/DepotBookStore.view.xml 393 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
igds-core/src/main/java/com/ld/igds/view/DepotBookStorePR.java 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
igds-core/src/main/java/com/ld/igds/view/service/HDepotBookStoreService.java 91 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
igds-core/src/main/java/com/ld/igds/view/DepotBookStore.view.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,393 @@
<?xml version="1.0" encoding="UTF-8"?>
<ViewConfig>
  <Arguments/>
  <Context/>
  <Model>
    <DataType name="dtMain">
      <Property name="creationType">com.ld.igds.models.DepotBookStore</Property>
      <PropertyDef name="id">
        <Property></Property>
      </PropertyDef>
      <PropertyDef name="companyId">
        <Property></Property>
        <Property name="label">组织编码</Property>
      </PropertyDef>
      <PropertyDef name="kqdm">
        <Property></Property>
        <Property name="label">库区代码</Property>
      </PropertyDef>
      <PropertyDef name="lspzdm">
        <Property></Property>
        <Property name="label">粮食品种代码</Property>
        <Property name="required">true</Property>
        <Property name="mapping">
          <Property name="keyProperty">code</Property>
          <Property name="valueProperty">name</Property>
          <Property name="mapValues">${dorado.getDataProvider(&quot;dicTriggerPR#dicTrigger&quot;).getResult(&quot;FOOD_VARIETY_&quot;)}</Property>
        </Property>
      </PropertyDef>
      <PropertyDef name="nd">
        <Property></Property>
        <Property name="label">年度</Property>
        <Property name="required">true</Property>
      </PropertyDef>
      <PropertyDef name="yf">
        <Property></Property>
        <Property name="label">月份</Property>
        <Property name="required">true</Property>
        <Property name="mapping">
          <Property name="keyProperty">key</Property>
          <Property name="valueProperty">value</Property>
        </Property>
      </PropertyDef>
      <PropertyDef name="qcsl">
        <Property name="dataType">Double</Property>
        <Property name="label">期初数量</Property>
        <Property name="required">true</Property>
      </PropertyDef>
      <PropertyDef name="bqsrsl">
        <Property name="dataType">Double</Property>
        <Property name="label">本期收入数量</Property>
        <Property name="required">true</Property>
        <Property name="displayFormat">#0.000KG</Property>
      </PropertyDef>
      <PropertyDef name="bqzcsl">
        <Property name="dataType">Double</Property>
        <Property name="label">本期支出数量</Property>
        <Property name="required">true</Property>
        <Property name="displayFormat">#0.000KG</Property>
      </PropertyDef>
      <PropertyDef name="qmye">
        <Property name="dataType">Double</Property>
        <Property name="label">期末数量</Property>
        <Property name="required">true</Property>
        <Property name="displayFormat">#0.000KG</Property>
      </PropertyDef>
      <PropertyDef name="yjbz">
        <Property name="dataType">Integer</Property>
        <Property name="label">月结标志</Property>
        <Property name="required">true</Property>
        <Property name="mapping">
          <Property name="keyProperty">key</Property>
          <Property name="valueProperty">value</Property>
          <Property name="mapValues">
            <Collection>
              <Entity>
                <Property name="key">0</Property>
                <Property name="value">月结</Property>
              </Entity>
              <Entity>
                <Property name="key">1</Property>
                <Property name="value">未月结</Property>
              </Entity>
            </Collection>
          </Property>
        </Property>
      </PropertyDef>
      <PropertyDef name="ywrq">
        <Property name="dataType">Date</Property>
        <Property name="label">业务日期</Property>
        <Property name="required">true</Property>
      </PropertyDef>
      <PropertyDef name="czbz">
        <Property></Property>
        <Property name="label">操作标志</Property>
        <Property name="mapping">
          <Property name="keyProperty">key</Property>
          <Property name="valueProperty">value</Property>
          <Property name="mapValues">
            <Collection>
              <Entity>
                <Property name="key">i</Property>
                <Property name="value">新增数据</Property>
              </Entity>
              <Entity>
                <Property name="key">u</Property>
                <Property name="value">修改数据</Property>
              </Entity>
              <Entity>
                <Property name="key">d</Property>
                <Property name="value">删除数据</Property>
              </Entity>
            </Collection>
          </Property>
        </Property>
      </PropertyDef>
      <PropertyDef name="zhgxsj">
        <Property name="dataType">DateTime</Property>
        <Property name="label">最后更新时间</Property>
      </PropertyDef>
    </DataType>
    <DataType name="dtParam">
      <PropertyDef name="foodVariety">
        <Property name="label">粮食品种</Property>
        <Property name="mapping">
          <Property name="mapValues">${dorado.getDataProvider(&quot;dicTriggerPR#dicTrigger&quot;).getResult(&quot;FOOD_VARIETY_&quot;)}</Property>
          <Property name="keyProperty">code</Property>
          <Property name="valueProperty">name</Property>
        </Property>
      </PropertyDef>
      <PropertyDef name="year">
        <Property name="label">年度</Property>
      </PropertyDef>
    </DataType>
  </Model>
  <View layout="padding:5;regionPadding:5">
    <Property name="packages">font-awesome,css-common</Property>
    <DataSet id="dsMain">
      <Property name="dataType">[dtMain]</Property>
      <Property name="dataProvider">depotBookStorePR#pageList</Property>
      <Property name="pageSize">15</Property>
    </DataSet>
    <DataSet id="dsParam">
      <ClientEvent name="onReady">self.insert({})&#xD;
</ClientEvent>
      <Property name="dataType">[dtParam]</Property>
    </DataSet>
    <Container layout="regionPadding:10" layoutConstraint="top">
      <Property name="exClassName">bg-color</Property>
      <Property name="height">55</Property>
      <Label layoutConstraint="left">
        <Property name="text">菜单栏:</Property>
      </Label>
      <Button layoutConstraint="left">
        <ClientEvent name="onClick">view.get(&quot;#dsMain&quot;).insert();&#xD;
view.get(&quot;#dialogMain&quot;).show();</ClientEvent>
        <Property name="exClassName">btn-normal</Property>
        <Property name="iconClass">fa fa-plus</Property>
        <Property name="caption">新增</Property>
      </Button>
      <Button layoutConstraint="left">
        <ClientEvent name="onClick">var dialog= view.get(&quot;#dsMain.data:#&quot;);&#xD;
if(dialog){&#xD;
    view.get(&quot;#dialogMain&quot;).show();&#xD;
}else{&#xD;
    $alert(&quot;请选中需要修改的数据&quot;)&#xD;
}</ClientEvent>
        <Property name="caption">编辑</Property>
        <Property name="exClassName">btn-warm</Property>
        <Property name="iconClass">fa fa-pencil</Property>
      </Button>
      <Button>
        <ClientEvent name="onClick">var cur = view.get(&quot;#dsMain.data:#&quot;);&#xD;
if(!cur) return;&#xD;
view.get(&quot;#ajaxDel&quot;).set(&quot;parameter&quot;,cur).execute(function(result){&#xD;
    if(result){&#xD;
        $alert(result);&#xD;
        return;&#xD;
    }else{&#xD;
        cur.remove();&#xD;
    }&#xD;
});</ClientEvent>
        <Property name="exClassName">btn-warn</Property>
        <Property name="iconClass">fa fa-pencil</Property>
        <Property name="caption">删除</Property>
      </Button>
    </Container>
    <Container>
      <AutoForm>
        <Property name="dataSet">dsParam</Property>
        <Property name="cols">*,*,*,*</Property>
        <AutoFormElement>
          <Property name="name">foodVariety</Property>
          <Property name="property">foodVariety</Property>
          <Editor/>
        </AutoFormElement>
        <AutoFormElement>
          <Property name="name">year</Property>
          <Property name="property">year</Property>
          <Property name="trigger">defaultYearDropDown</Property>
          <Editor/>
        </AutoFormElement>
        <Container layout="regionPadding:10">
          <Button layoutConstraint="left">
            <ClientEvent name="onClick">var param = view.get(&quot;#dsParam.data:#&quot;);&#xD;
view.get(&quot;#dsMain&quot;).set(&quot;parameter&quot;,param).flushAsync();</ClientEvent>
            <Property name="caption">查询</Property>
            <Property name="exClassName">btn-normal</Property>
            <Property name="iconClass">fa fa-search</Property>
          </Button>
          <Button layoutConstraint="left">
            <ClientEvent name="onClick">view.get(&quot;#dsParam&quot;).insert({})</ClientEvent>
            <Property name="caption">重置</Property>
            <Property name="iconClass">fa fa-refresh</Property>
            <Property name="exClassName">btn-default</Property>
          </Button>
        </Container>
      </AutoForm>
      <DataGrid id="dgMain">
        <ClientEvent name="onDataRowDoubleClick">view.get(&quot;#dialogMain&quot;).show();</ClientEvent>
        <Property name="dataSet">dsMain</Property>
        <Property name="readOnly">true</Property>
        <RowNumColumn/>
        <DataColumn name="lspzdm">
          <Property name="property">lspzdm</Property>
          <Property name="align">center</Property>
        </DataColumn>
        <DataColumn name="nd">
          <Property name="property">nd</Property>
          <Property name="align">center</Property>
        </DataColumn>
        <DataColumn name="yf">
          <Property name="property">yf</Property>
          <Property name="align">center</Property>
        </DataColumn>
        <DataColumn name="qcsl">
          <Property name="property">qcsl</Property>
          <Property name="align">center</Property>
        </DataColumn>
        <DataColumn name="bqsrsl">
          <Property name="property">bqsrsl</Property>
          <Property name="align">center</Property>
        </DataColumn>
        <DataColumn name="bqzcsl">
          <Property name="property">bqzcsl</Property>
          <Property name="align">center</Property>
        </DataColumn>
        <DataColumn name="qmye">
          <Property name="property">qmye</Property>
          <Property name="align">center</Property>
        </DataColumn>
        <DataColumn name="yjbz">
          <Property name="property">yjbz</Property>
          <Property name="align">center</Property>
        </DataColumn>
        <DataColumn name="ywrq">
          <Property name="property">ywrq</Property>
          <Property name="align">center</Property>
        </DataColumn>
        <DataColumn name="czbz">
          <Property name="property">czbz</Property>
          <Property name="align">center</Property>
        </DataColumn>
        <DataColumn name="zhgxsj">
          <Property name="property">zhgxsj</Property>
          <Property name="align">center</Property>
        </DataColumn>
      </DataGrid>
      <ToolBar layoutConstraint="bottom">
        <Fill/>
        <DataPilot>
          <Property name="dataSet">dsMain</Property>
          <Property name="itemCodes">pageSize,pages</Property>
        </DataPilot>
      </ToolBar>
    </Container>
    <Dialog id="dialogMain">
      <Property name="caption">库存信息</Property>
      <Property name="width">800</Property>
      <Property name="closeable">false</Property>
      <Buttons>
        <Button>
          <ClientEvent name="onClick">var data = view.get(&quot;#dsMain.data:#&quot;);&#xD;
view.get(&quot;#uaAction&quot;).execute(function(result){&#xD;
    if(result){&#xD;
        $alert(result);&#xD;
    }else{&#xD;
        self.get(&quot;parent&quot;).hide();&#xD;
    }&#xD;
});</ClientEvent>
          <Property name="caption">保存</Property>
          <Property name="iconClass">fa fa-check</Property>
          <Property name="exClassName">btn-normal</Property>
        </Button>
        <Button>
          <ClientEvent name="onClick">view.get(&quot;#dsMain.data:#&quot;).cancel();&#xD;
self.get(&quot;parent&quot;).hide();</ClientEvent>
          <Property name="caption">取消</Property>
          <Property name="iconClass">fa fa-times</Property>
          <Property name="exClassName">btn-warn</Property>
        </Button>
      </Buttons>
      <Children>
        <AutoForm>
          <Property name="dataSet">dsMain</Property>
          <Property name="readOnly">false</Property>
          <Property name="labelSeparator"> : </Property>
          <Property name="labelAlign">right</Property>
          <Property name="cols">*,*</Property>
          <Property name="labelWidth">120</Property>
          <AutoFormElement>
            <Property name="name">lspzdm</Property>
            <Property name="property">lspzdm</Property>
            <Editor/>
          </AutoFormElement>
          <AutoFormElement>
            <Property name="name">nd</Property>
            <Property name="property">nd</Property>
            <Property name="trigger">defaultYearDropDown</Property>
            <Editor/>
          </AutoFormElement>
          <AutoFormElement>
            <Property name="name">yf</Property>
            <Property name="property">yf</Property>
            <Property name="trigger">monthDropDown1</Property>
            <Editor/>
          </AutoFormElement>
          <AutoFormElement>
            <Property name="name">qcsl</Property>
            <Property name="property">qcsl</Property>
            <Editor/>
          </AutoFormElement>
          <AutoFormElement>
            <Property name="name">bqsrsl</Property>
            <Property name="property">bqsrsl</Property>
            <Editor/>
          </AutoFormElement>
          <AutoFormElement>
            <Property name="name">bqzcsl</Property>
            <Property name="property">bqzcsl</Property>
            <Editor/>
          </AutoFormElement>
          <AutoFormElement>
            <Property name="name">qmye</Property>
            <Property name="property">qmye</Property>
            <Editor/>
          </AutoFormElement>
          <AutoFormElement>
            <Property name="name">yjbz</Property>
            <Property name="property">yjbz</Property>
            <Editor/>
          </AutoFormElement>
          <AutoFormElement>
            <Property name="name">ywrq</Property>
            <Property name="property">ywrq</Property>
            <Editor/>
          </AutoFormElement>
          <AutoFormElement>
            <Property name="name">czbz</Property>
            <Property name="property">czbz</Property>
            <Editor/>
          </AutoFormElement>
          <AutoFormElement>
            <Property name="name">zhgxsj</Property>
            <Property name="property">zhgxsj</Property>
            <Editor/>
          </AutoFormElement>
        </AutoForm>
      </Children>
      <Tools/>
    </Dialog>
    <UpdateAction id="uaAction">
      <Property name="successMessage">执行成功!</Property>
      <Property name="dataResolver">depotBookStorePR#saveData</Property>
      <UpdateItem>
        <Property name="dataSet">dsMain</Property>
        <Property name="dataPath">[#current]</Property>
      </UpdateItem>
    </UpdateAction>
    <AjaxAction id="ajaxDel">
      <Property name="confirmMessage">确定要删除吗?</Property>
      <Property name="service">depotBookStorePR#delData</Property>
    </AjaxAction>
    <MonthDropDown id="monthDropDown1">
      <ClientEvent name="onClose">var date = arg.selectedValue+1;&#xD;
if(date&lt;10){&#xD;
    arg.selectedValue=&quot;0&quot;+date&#xD;
}else if(date>=10){&#xD;
    arg.selectedValue=date&#xD;
}&#xD;
</ClientEvent>
    </MonthDropDown>
  </View>
</ViewConfig>
igds-core/src/main/java/com/ld/igds/view/DepotBookStorePR.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,56 @@
package com.ld.igds.view;
import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.annotation.DataResolver;
import com.bstek.dorado.annotation.Expose;
import com.bstek.dorado.data.provider.Page;
import com.ld.igds.models.DepotBookStore;
import com.ld.igds.view.service.HDepotBookStoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Map;
/**
 * @Author: YYC
 * @Description:
 * @DateTime: 2023/10/20 18:37
 **/
@Component
public class DepotBookStorePR {
    @Autowired
    private HDepotBookStoreService bookStoreService;
    /**
     * depotBookStorePR#pageList
     *
     * @param page
     * @param param
     * @throws Exception
     */
    @DataProvider
    public void pageList(Page<DepotBookStore> page, Map<String, Object> param) throws Exception {
        bookStoreService.listBookStore(page, param);
    }
    /**
     * depotBookStorePR#saveData
     *
     * @param data
     */
    @DataResolver
    public void saveData(DepotBookStore data) {
        bookStoreService.saveData(data);
    }
    /**
     * depotBookStorePR#delData
     *
     * @param data
     */
    @Expose
    public void delData(DepotBookStore data) {
        bookStoreService.delData(data);
    }
}
igds-core/src/main/java/com/ld/igds/view/service/HDepotBookStoreService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,91 @@
package com.ld.igds.view.service;
import com.bstek.bdf2.core.orm.hibernate.HibernateDao;
import com.bstek.dorado.data.provider.Page;
import com.ld.igds.models.DepotBookStore;
import com.ld.igds.util.ContextUtil;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.Session;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
 * @Author: YYC
 * @Description:账面库存
 * @DateTime: 2023/10/20 14:56
 **/
@Component
public class HDepotBookStoreService extends HibernateDao {
    public void listBookStore(Page<DepotBookStore> page, Map<String, Object> param) throws Exception {
        StringBuffer hql = new StringBuffer();
        hql.append(" from " + DepotBookStore.class.getName() + " where companyId =:companyId and kqdm =:deptId ");
        Map<String, Object> args = new HashMap<>();
        args.put("companyId", ContextUtil.getCompanyId());
        args.put("deptId", ContextUtil.subDeptId(null));
        if (null != param) {
            buildHql(hql, param, args);
        }
        String count = "select count(*) " + hql.toString();
        hql.append(" order by zhgxsj desc");
        this.pagingQuery(page, hql.toString(), count, args);
    }
    public void saveData(DepotBookStore data) {
        data.setZhgxsj(new Date());
        Session session = this.getSessionFactory().openSession();
        try {
            if (null == data.getId()) {
                data.setId(ContextUtil.getUUID());
                data.setKqdm(ContextUtil.subDeptId(null));
                data.setCompanyId(ContextUtil.getCompanyId());
                data.setCzbz("i");
                session.save(data);
            } else {
                data.setCzbz("u");
                session.update(data);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            session.flush();
            session.close();
        }
    }
    public void delData(DepotBookStore data) {
        Session session = this.getSessionFactory().openSession();
        try {
            if (null != data.getId()) {
                session.delete(data);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            session.flush();
            session.close();
        }
    }
    public void buildHql(StringBuffer hql, Map<String, Object> param, Map<String, Object> args) {
        String str = (String) param.get("foodVariety");
        if (StringUtils.isNotEmpty(str)) {
            hql.append(" and lspzdm =:foodVariety");
            args.put("foodVariety", str);
        }
        Integer year = (Integer) param.get("year");
        if (null != year) {
            hql.append(" and nd =:year");
            args.put("year", String.valueOf(year));
        }
    }
}